So I am using the FileStream inside XmlReader
using (XmlReader reader = XmlReader.Create(new FileStream(archivePath, FileMode.Open), readerSettings))
{
reader.close()
}
However, the file feed into the XmlReader is still in the lock state after the using scope, weird, I thought the XmlReader is going to close the FileStream for me, is it not?
Thanks for help.
Have you tried this?
I couldn’t find anything in the documentation that explicitly stated that the
XmlReaderwould call dispose on the underlying stream when it was disposed. Also, I always use it as shown above and I have never encountered a problem.Browsing through reflector I also find no instances where it calls
Dispose()on the stream when creating aXmlTextReaderImpl. TheXmlTextReaderImpldoes not implementDispose()and itsClose()method looks like this: