Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to check for EOF (End of file) when using StreamReader to parse text file

Reply
Thread Tools

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

 
 
Sacha Korell
Guest
Posts: n/a
 
      09-05-2003
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


 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      09-05-2003
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" <(E-Mail Removed)> wrote in message
news:O$ppRs%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      09-06-2003
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Windows] Any way to distinguish ^C Induced EOF from ^Z EOF? Jan Burse Java 67 03-14-2012 12:21 AM
ifstream eof not reporting eof? SpreadTooThin C++ 10 06-15-2007 08:49 AM
Streamreader is holding a text file in its grip after it is closed damezumari ASP .Net 2 04-27-2006 02:28 PM
In file parsing, taking the first few characters of a text file after a readfile or streamreader file read... .Net Sports ASP .Net 11 01-17-2006 12:44 AM
if EOF = -1, can't a valid character == EOF and cause problems? Kobu C Programming 10 03-04-2005 10:40 PM



Advertisments