This is a common problem that I have encountered with an XML author in the past. If the used Filestream is not closed properly, the file will remain locked. I say this is a problem, mainly because I noticed that for some reason the lock remains even after the application is closed, but I saw how it happens when I use the XML writer in this way (I donβt know why else).
Basically, just use the "using" keyword to make sure your writer is properly closed. The code should look something like this:
using(XmlWriter _myXmlWriter = XmlWriter.Create(outputStream, xmlWriterSettings)) {
source share