473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

StreamWriter...

37
Hi All,

I want to create StreamWriter object in shared.write mode

i am writing below code to create an object .

Dim objSW As StreamWriter = New StreamWriter(sExportFolder & "\" & sSession & ".CSV")

how can i create in shared mode.

like we can do in FileStream i.e. fi.open("ADC",fi.read,fi.fileshare.write)

Thanks in advance

-john
Jul 21 '08 #1
2 1617
Curtis Rutland
3,256 Expert 2GB
Create the FileStream first, and then create the StreamWriter from the FileStream.

example
Expand|Select|Wrap|Line Numbers
  1. Dim fs as new FileStream(whateverYouNeedHere)
  2. Dim sw as new StreamWriter(fs)
  3.  
Jul 21 '08 #2
joedeene
583 512MB
i dont really understand what you want to do, but no i dont believe you can open a streamwriter in shared mode, or something, but you can combine those in a way to be useful,

example:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrite.Click
  2.              writer()
  3.     End Sub
  4.  
  5. Private Sub writer()
  6.         Dim filestream As New FileStream("C:\Test.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Write)
  7.         Dim mynewstreamwriter As New StreamWriter(filestream)
  8.         mynewstreamwriter.WriteLine("I Think This Will Work...")
  9.         mynewstreamwriter.Flush()
  10.         mynewstreamwriter.Close()
  11.         filestream.Close()
  12.     End Sub
because all the streamwriter does, well is self-explanatory, it writes to a stream. and the io.filestream is just a stream that you can change and/or set options and permissions for. so you can combine them both to do something like that. but im not really an expert, so im not 100% sure, but when i tried it, it did create a text file with the text...
Jul 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: | last post by:
Hi, When constructing StreamWriter with the following.. FileStream f = new FileStream(..); StreamWriter s = new StreamWriter(f); Then attempt to write out هنِ letters they become garbage. ...
1
by: Vladimir Bezugliy | last post by:
I have a server that listen a socket. And I have next client: TcpClient socketForServer = new TcpClient("IVBEZUGLIY", 21000); NetworkStream networkStream = socketForServer.GetStream();...
4
by: Majed | last post by:
Hi , all I'm trying to write unicode to a file for another app (not developed with vs2003) to read it. I used StreamWriter with unicode encoding.but I was surprised that the streamwriter adds FFFE...
1
by: Daniel | last post by:
i would like to konw when the data sent so that i can close the streamwriter and networkstream is there some sort of call backs/events i have to implement for this to work? if so how? can i just...
1
by: Lars Hansen | last post by:
Hi This is probably pretty basic, but I have a problem with the access-level (local variable), when creating a new StreamWriter. I am trying to write some price information to a textfile - which...
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
4
by: rex64 | last post by:
I am getting an error message and I have not been able to figure hot how to fix it. I have done some research with no answers yet. I found this code that may help? Not sure what to do with it....
10
by: Oscar Thornell | last post by:
Hi, I generate and temporary saves a text file to disk. Later I upload this file to Microsoft MapPoint (not so important). The file needs to be in UTF-8 encoding and I explicitly use the...
1
by: Max Powers | last post by:
Hello, I have a VB.NET code that creates a StreamWriter file first and then it does a series of procedures that write lines for this StreamWriter. When all the procedures are done, the...
4
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.