Hi,
You can't using Streamreader for the same reason you expose. the solution
may be using a stream that does gives you the Position and then decorate it
with streamreader to have the "line" functionality.
Use a FileStream to open the file and them create a streamreader around it.
you could use FileStream.Position to know the position.
Even so, this may not be the solution, as the FileStream.Position will give
you what streamreader has readed, not what you consume.
Try it, if it does not work. you have to implement it . I think I have such
a code, I used it for a PPC application to read from a networkstream and
have a ReadString () like method. let me know if you need the code
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Keith Kingsley" <Ke***********@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
I'm using a StreamReader to read in several lines from an ASCII file. I'd
like to know the StreamReader's "true" position-- that is, the number of
bytes into the file that the StreamReader has read. I thought about using
MyStreamReader.BaseStream.Position, but this always seems to return a
multiple of the StreamReader's buffer size (which seems natural-- as I
understand it the StreamReader reads from the underlying stream in
discrete
blocks corresponding to the buffer size). I also considered counting the
bytes myself (as I read into the file), but ReadLine() doesn't record
whether
the returned line ended in a CR, an LR, or both.
Any ideas?
Thanks,
Keith Kingsley
--
What if there were no hypothetical situations?