XmlDocument.WriteTo truncates resultant file
Posted
by Brad Heller
on Stack Overflow
See other posts from Stack Overflow
or by Brad Heller
Published on 2010-06-08T22:55:50Z
Indexed on
2010/06/08
23:42 UTC
Read the original article
Hit count: 272
Trying to serialize an XmlDocument to file. The XmlDocument is rather large; however, in the debugger I can see that the InnerXml property has all of the XML blob in it -- it's not truncated there.
Here's the code that writes my XmlDocument object to file:
// Write that string to a file.
var fileStream = new FileStream("AdditionalData.xml", FileMode.OpenOrCreate, FileAccess.Write);
xmlDocument.WriteTo(new XmlTextWriter(fileStream, Encoding.UTF8) {Formatting = Formatting.Indented});
fileStream.Close();
The file that's produced here only writes out to line like 5,760 -- it's actually truncated in the middle of a tag!
Anyone have any ideas why this would truncate here?
© Stack Overflow or respective owner