help readin text file

M

Marc

So i have a text file where each line represents a button name.

What the code I need to read this file and creatre a new button from
each line..


so far I just have code to read the whole file


Dim TextFileStream As System.IO.TextReade
TextFileStream = System.IO.File.OpenText("C:\MyTextFile.txt")
Dim MyFileContents As String = TextFileStream.ReadToEnd
 
B

Branco Medeiros

Marc wrote:
Dim TextFileStream As System.IO.TextReade
TextFileStream = System.IO.File.OpenText("C:\MyTextFile.txt")
Dim MyFileContents As String = TextFileStream.ReadToEnd

Cool!

You learn a new thing everyday. Having seen System.IO.File.OpenText, I
wondered if there was something like 'ReadToEnd'. And so it has:

Dim Text As String = System.IO.File.ReadAllText(FileName)

or, if you prefer it already split into lines:

Dim Lines() As String = System.IO.File.ReadAllLines(FileName)


Regards,

Branco.
 

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