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?
rmmarshAsked:
Who is Participating?
 
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
 
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
 
rmmarshAuthor Commented:
Thank you again... I appreciate it...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.