system.io.streamreader.readline
-
I'm trying to parse a text file using the .readline() method of streamreader. My problem is that my code (below) won't work with text files that have blank lines. It thinks this is an 'end of the file' statement. Is there something else i can test in the conditional statement besides "Do until strLine = Nothing" so that i can read even a blank line and read the file straight through to the 'real' end of file? --------------------------- strLine = srdCurrent.ReadLine() Do Until strLine = Nothing strFile += strLine & CrLf strLine = srdCurrent.ReadLine() Loop ----------------------------
-
I'm trying to parse a text file using the .readline() method of streamreader. My problem is that my code (below) won't work with text files that have blank lines. It thinks this is an 'end of the file' statement. Is there something else i can test in the conditional statement besides "Do until strLine = Nothing" so that i can read even a blank line and read the file straight through to the 'real' end of file? --------------------------- strLine = srdCurrent.ReadLine() Do Until strLine = Nothing strFile += strLine & CrLf strLine = srdCurrent.ReadLine() Loop ----------------------------
-
Try this example, it reads from a file (including blank lines) into a TextBox: Dim file As New IO.StreamReader("c:\temp\test.txt") While file.Peek > 0 TextBox1.Text += file.ReadLine() & vbCrLf End While file.Close() Hope this helps Tom
-
i would do it differently, instead of peeking into the file (which is generally not a good thing to do due to various reasons) use this statement instead
while MyStramReader.BaseStream.Position < MyStramReader.BaseStream.Length ...
should also work faster :) (i think...) Fade (Amit BS) -
i would do it differently, instead of peeking into the file (which is generally not a good thing to do due to various reasons) use this statement instead
while MyStramReader.BaseStream.Position < MyStramReader.BaseStream.Length ...
should also work faster :) (i think...) Fade (Amit BS)