XmlDocument.WriteTo method truncating at 2048 characters

  • Thread starter Thread starter William
  • Start date Start date
W

William

I am attempting to write an XmlDocument to file, but for some reason it will
only write 2048 characters of the document even though when I stop it in the
debugger ALL of the document is there.

Code snippet is as follows:

XmlDocument xml = new XmlDocument();
xml.LoadXml(Encoding.UTF8.GetString(btResponse));
XmlTextWriter w = new XmlTextWriter("..\\..\\..\\xml\\Test.xml", null);
xml.WriteTo(w); // will not write anything after 2048 bytes

Any suggestions?
 
William said:
I am attempting to write an XmlDocument to file, but for some reason it will
only write 2048 characters of the document even though when I stop it in the
debugger ALL of the document is there.

Code snippet is as follows:

XmlDocument xml = new XmlDocument();
xml.LoadXml(Encoding.UTF8.GetString(btResponse));
XmlTextWriter w = new XmlTextWriter("..\\..\\..\\xml\\Test.xml", null);
xml.WriteTo(w); // will not write anything after 2048 bytes

Any suggestions?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

My guess is that you're not disposing it, so the underlying stream
isn't getting closed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top