• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

How to set the textreader to beginning after doing a read?

I have some code that uses TextReader to look for errors in the XML file before any processing.  I'm using:

                textReader.ResetState();  //  reset it...

but it doesn't seem to be setting it back to the beginning of the stream (or file).

How to fix this so I can read the TextReader from the beginning?
0
rmmarsh
Asked:
rmmarsh
  • 2
1 Solution
 
jppintoCommented:
Please try one of this:

textReader.BaseStream.Seek(0, SeekOrigin.Begin);
textReader.DiscardBufferedData();

textReader.BaseStream.Position = 0;
textReader.DiscardBufferedData();
0
 
rmmarshAuthor Commented:
Error      10      'System.Xml.XmlTextReader' does not contain a definition for 'BaseStream'
 and no extension method 'BaseStream' accepting a first argument of type 'System.Xml.XmlTextReader' could be found
0
 
strickddCommented:
XmlTextReader does not provide this functionality. Here are a couple alternatives:

http://social.msdn.microsoft.com/forums/en-US/xmlandnetfx/thread/4a982ea0-b2d9-4d77-807b-1cb82e356554
0
 
rmmarshAuthor Commented:
Thank you again... I appreciate it...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now