[2005] The problem of sr.EndOfStream when the last line holds data
Hi,
When I process a text file, I do so line-by-line using:
...but if the last line of the file contains data (i.e. there are no blank lines at the bottom), the last line doesn't get read. I do a workaround for this by opening up a file, adding a line then opening it up again to process. Pretty bad, huh?!
So what's the best way to get around the 'last line with data' prob? I suspect it might have something to do with "Peek", which I've never used. :eek:
Thank you!
Re: [2005] The problem of sr.EndOfStream when the last line holds data
Would that change things?
If not then peek is done like so:
VB Code:
Do until sr.Peek = -1
msgbox sr.read
Loop
You have to use Read or ReadLine inside the loop (duh) or else the loop will continue...forever! ;)