I'm using C# with .NET 4.0 and I'm trying to debug a rare problem with my application where sometimes the program will take my .xml file I read and write configuration settings to and will write a blank XML file.
The problem is I can't recreate it after exhaustive attempts to do so, so I thought I might make sure there isn't a known situation where the built in XmlDocument.Save()
feature could result in a blank file.
The only way the XML file is ever modified is in memory using the built in XmlNode.AppendChild()
and XmlNode.ReplaceChild()
so I expect either the problem happens in one of those functions or on write to disk with the XmlDocument.Save()
function.
I found this thread. Especially the second last Answer might be worth a try. Quote:
A workaround which appears to work was to replace:
doc.Save("c:\temp\Output.xml")
with
IO.File.WriteAllText("c:\temp\Output.xml", doc.OuterXml);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With