The StreamWriter class is derived from the
TextWriter class and can be used to write text to a stream. You can create an
instance of the StreamWriter class by assigning it a Stream object returned by a
method call, or by passing a file path to one of its constructors.the first
parameter is the file name and second parameter is optional, boolean type. If
second parameter is true, an existing file will be appended with new text.
For example
In this example we take a textfile and write
some text in this file using StreamWriter class. Firstly give namespace
System.IO.
Imports
System.IO
Module
Module1
Sub Main()
Dim write1 As
StreamWriter = New
StreamWriter("Textfile.txt")
write1.Write("This
is the text file ")
write1.WriteLine("This
file contain some text")
write1.WriteLine("-------------------")
write1.Write("The
date is: ")
write1.WriteLine(DateTime.Now)
write1.Close()
End Sub
End
Module