Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

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

Code today gone tomorrow!
Guest mutant
Posted
Add MyFile.Flush() before closing to make sure you dont loose any text that you want to write into the file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...