ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

37- 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
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!