Dim x As New IO.StreamReader(OpenFileDialog1.FileName)
TextBox1.Text = x.ReadToEnd
x.Close()
Using sRead As New IO.StreamReader("File")
Dim Line1 As String = sRead.ReadLine
Dim Line2 As String = sRead.ReadLine
Dim Line3 As String = sRead.ReadLine
Dim Line4 As String = sRead.ReadLine
Dim Line5 As String = sRead.ReadLine
'etc....
End Using
That is to read line by line as you said, If you want to read Everything then say it :P
Posts 1–7 of 7 · Page 1 of 1
Post a Reply
Tags for this Thread
None
[highlight=vb.net]
Dim sReader As New IO.StreamRead("C:\textfile.txt")
Dim txtContents As String = String.Empty
While Not sReader.EndOfStream
txtContents += sReader.ReadLine & vbNewLine
End While
sReader.Close
[/highlight]
anyone know a For Each?
Dim sReader As New IO.StreamRead("C:\textfile.txt")
Dim txtContents As String = String.Empty
While Not sReader.EndOfStream
* * txtContents += sReader.ReadLine & vbNewLine
End While
sReader.Close
[highlight=vb.net]
Dim totalLines As String() = IO.File.ReadAllLines("C:\Example\yeah.txt")
For each line As String in totalLines
'....
Next
[/highlight]