I am trying to write text to a disk file. I dimensioned a variable, sr, as StreamWriter and used the line sr.WriteLine(strPage) to write the text to the file but all it does is open an empty file and does not write the text to the file. I know there is something in strPage because I also write it to a textbox on my form. Can someone please help
Don

Writing to a text file
Craigster
rgreene_blizzard
Coreen
Dim sw as new IO.StreamWriter("C:\myFile.txt")
sw.WriteLine("This is a line of text")
sw.Close()
Dautov
Dim
tempFile As String = My.Computer.FileSystem.GetTempFileName Dim sw As New IO.StreamWriter(New IO.FileStream(tempFile, IO.FileMode.Open Or IO.FileMode.CreateNew))sw.WriteLine(
"hello")you can use FileStream to control how you want to open file (Open file, create new file... etc)
DBD
Hi,
You can use the sample code snipplet.
Note that LogData is a string variable and LogFile is a string variable pointing to the path of the file.
Dim objStreamWriter As StreamWriterobjStreamWriter =
New StreamWriter(LogFile, True, Encoding.Unicode) objStreamWriter.WriteLine(LogData)objStreamWriter.Close()
objStreamWriter =
NothingEralper
http://www.kodyaz.com
jesusislove333333
WHat version of VB are you running