37- Saving Text Files

0
306

This Visual Basic Tutorial is all about Saving Text Files.
Writing to a text file is the same as reading a text file but in here, instead of using the StreamReader we will use the StreamWriter which is used to write a stream of text to a file.

 

example:

  1. If System.IO.File.Exists("C:\testfile.txt") = True Then
  2.  
  3. Dim fWriter As New System.IO.StreamWriter(" C:\testfile.txt")
  4.  
  5. fWriter.Write("itsourcode.com")
  6. fWriter.Close()
  7.  
  8. MsgBox("The text is written to the file.")
  9.  
  10. Else
  11.  
  12. MsgBox("The .txt file does not exist.")
  13. End If

 

 

Reader might read also:

Facebook Comments
(Visited 24 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here