Good day, Hashcode.
Something I can’t see into one thing:
When working with xml, if I take a file from a stream, a copy of the XDocument is created:
if (doc == null) { doc = XDocument.Load(stream, LoadOptions.None); } doc.Element("someElement").Add(... );
When saving to the stream, the contents of this file is added to the tail of the existing one.
doc.Save(stream);
It turns out in the end a rare nonsense (the original file does not go anywhere, just a corrected file is added to it in the tail, which is nonsense).
How to make
- Is the saved xml file overwriting the file from the stream?
- Well, or alternatively - the file was opened from the stream for a change, and did not create a local copy.
In theory, it should be simple, but something I'm stupid today ... :)