Open Text File

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
 
Y

Yonas Hagos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top