This is somewhat trivial but here goes. I am passing an XmlTextReader object to a method using .Net 4.0 framework.
public void TestMethod(XmlTextReader reader)
{
try
{
//...
//Logic
//...
}
catch(Exception ex)
{
//I also want to log the file location of the XmlTextReader!
Log(ex.Message);
}
}
If something happens to the reader I want to log where the file the XmlTextReader is reading from. Is there an easy way to get back to the stream the XmlTextReader is using? The reason it is somewhat trivial is that I could easily pass in an additional string to the method containing the file location used to create the stream, but it just seems that has to be a way using only the XmlTextReader.
Thanks!
Update, this is actually what I'm doing... Sorry for the bad example:
public void TestMethod(XmlTextReader reader)
{
//...
//Logic
//...
if(something_inside_the_XML)
throw new Exception(FileLocation);
}