I have an xml file that I use for the database, which means the xml is updated frequently. There is a FileWatcher for the xml database, and after updating the xml, I get an event, and then I deserialize the xml into an object and check if there were any changes.
The problem I have is that as soon as I deserialize the xml, Stream Reader blocks the file, so I can get exceptions when I try to update it.
Is it possible to deserialize xml without locking the file?
XmlSerializer serializer = new XmlSerializer(typeof (MyType)); Stream reader = new FileStream(File, FileMode.Open); var myType = (MyType) serializer.Deserialize(reader);
source share