Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check for EOF (End of file) when using StreamReader to parse text file

0 views
Skip to first unread message

Sacha Korell

unread,
Sep 5, 2003, 4:19:52 PM9/5/03
to
How would I check for an end of file when parsing a text file using the
StreamReader object?

I would like to do something like this:

'********************************
Dim objStreamReader As StreamReader
Dim strReqLine As String

objStreamReader = File.OpenText("data.txt")

While NOT objStreamReader.EOF

strReqLine = objStreamReader.ReadLine

'* Code to parse the line for data

End While
'********************************

Except the StreamReader object doesn't seem to have an EOF property. Are
there any work-arounds?

Thanks,

Sacha


S. Justin Gengo

unread,
Sep 5, 2003, 4:28:09 PM9/5/03
to
Sacha,

Just use:

While StreamReader.Read

End While

It will stop when it hits EOF.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


"Sacha Korell" <kor...@huntsville.sparta.com> wrote in message
news:O$ppRs%23cDH...@tk2msftngp13.phx.gbl...

Mattias Sjögren

unread,
Sep 6, 2003, 10:59:10 AM9/6/03
to
Sacha,

strReqLine = objStreamReader.ReadLine()
While Not strReqLine Is Nothing


'* Code to parse the line for data

strReqLine = objStreamReader.ReadLine()
End While

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

0 new messages