I'd like to re-use a StreamReader I've associated with an XML file for .Read()-Calls from System.Xml.XmlReader.
Basically I've put together a small extension method featuring the following code:
public static string GetValueByPath(this StreamReader str, string attributeName, params string[] nodes)
{
str.BaseStream.Position = 0;
XmlReader reader = XmlReader.Create(str);
// Stuff happens here now, not important for the question
}
The StreamReader calling this extension method stays the same throughout the whole Session.
The first time this works just fine, but if I use this method a second time I receive a System.Xml-Exception. Is there no way to effectively "reset" a StreamReader?
Thanks,
Dennis