36-Reading Text Files

0
288

This Visual Basic Tutorial is all about Reading Text Files.
The My.Computer.FileSystem object has a method that allows you to read a text file and it is called the ReadAllText.  The encoding file can be specified if the file contains an encoding text such as ASCII or UTF-8.

 

You need to specify the encoding file , if you are reading from a file with an extended characters.

 

Example:

  1. <pre>Dim fReader As String
  2. fReader = My.Computer.FileSystem.ReadAllText("C:\testfile.txt")
  3. MsgBox(fReader)

Example of Encoding File:

  1. Dim fReader As String
  2. fReader = My.Computer.FileSystem.ReadAllText("C:\testfile.txt",
  3.    System.Text.Encoding.UTF32)
  4. MsgBox(fReader)

 

 

Readers might read also:

 

Facebook Comments
(Visited 16 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here