Re: StreamReader how do I move to BOF? by Johnnie
Johnnie
Sun Oct 22 12:08:49 CDT 2006
Hey Pete, yes I saw yours and actually used it, thanks a lot.
JT.
Peter Duniho wrote:
> "Johnnie Walker" <tregoning@gmail.com> wrote in message
> news:1161464571.606966.8220@h48g2000cwc.googlegroups.com...
> > Thanks a lot! very useful!
>
> I don't know if you saw my reply, but Grzegorz's reply is insufficient. It
> does not account for the possibility of buffering within the StreamReader.
> You may use the Position property as he suggests, rather than the Seek()
> method I mentioned in my post, but in either case you need to call
> DiscardBufferedData() to ensure that when you read from the StreamReader
> after changing the position, you are actually reading from the new position.
>
> And of course it should go without saying that you should either make sure
> that you are always using a seekable stream (if you are always opening a
> disk file, this should be the case), or check the CanSeek property of the
> stream, or be prepared for a NotSupportedException being thrown. Not all
> Streams are seekable.
>
> Pete