VB.NET input output...

vidiware

Active member
Joined
Dec 3, 2002
Messages
39
In VB 6 you could write somehting like:

Open xxx for input as #1....

can someone explain me in detail how you opens a textfile for input or output in VB.NET?
 
Code:
Dim MyFile As IO.StreamWriter
MyFile = New System.IO.StreamWriter("c:\test.txt", True)  True for appending
MyFile.WriteLine("THIS IS A LINE OF TEXT")  Write text to file
MyFile.WriteLine("THIS IS ANOTHER")
MyFile.Close()  Close file

Hope this helps nice and easy

Andy
 
Add MyFile.Flush() before closing to make sure you dont loose any text that you want to write into the file.
 
Back
Top