Open Text File

  • Thread starter Thread starter Lumpierbritches
  • Start date Start date
L

Lumpierbritches

Thank you in advance for any and all assistance. Is there a way to open a
specific text file in Visual Basic.NET? If so, what is the code?

Michael
 
If I correctly understood your question, this piece of code will read line
by line from a text file and store into a string variable. You can then do
what ever you want with the returns.

Imports System.IO

Private Sub ReadRecord()


Dim filetoread As String

filetoread = "c:\MytextFile.txt"

Dim filestream As StreamReader

filestream = File.OpenText(filetoread)

Dim readcontents As String

Do Until filestream.Peek = -1

readcontents = filestream.ReadLine()

Loop


filestream.Close()


End Sub
 
Back
Top