Tag Archives: Writeline

Write Text to a Text File with Stream Writer Class using VB.NET

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("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.