Tag Archives: write text

This will use the Stream Writer class under the System.IO namespace to write text to a textfile.

'
'Write to text file with the Stream Writer Class
Dim sWriter As IO.StreamWriter = New IO.StreamWriter("c:\newTextFile.txt")
'This is pretty much easy to understand. No explanation
sWriter.WriteLine("Hi")
sWriter.WriteLine("Testing out this code")
sWriter.WriteLine("Hopefully this code will work")
sWriter.WriteLine("Lets flush the stream and see")
'Flush all data to the file.
sWriter.Flush()
sWriter.Close()