XmlTextReader - Does the file block?

This is probably a very simple thing, but I could not find it, and I probably just searched for the wrong thing ...

XmlTextReader -> Does it write the file you are reading? I use reader.Read () about it too.

+5
source share
1 answer

When you create a new XmlTextReader, submitter string, it locks the file with write lock (but not read lock); however, if you provide it Stream, it will depend on the flow itself.

FileStream stream = new FileStream(@"myfile.xml", FileMode.Open,
                            FileAccess.Read, FileShare.ReadWrite);
XmlTextReader reader = new XmlTextReader(stream);

Now you can read without blocking.

+19
source

All Articles