Link to home
Start Free TrialLog in
Avatar of rmmarsh
rmmarshFlag for United States of America

asked on

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?
Avatar of jppinto
jppinto
Flag of Portugal image

Please try one of this:

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

textReader.BaseStream.Position = 0;
textReader.DiscardBufferedData();
Avatar of rmmarsh

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

ASKER

Thank you again... I appreciate it...