xmlnode.writeto > memorystream gets truncated

  • Thread starter Kristofer Andersson
  • Start date
K

Kristofer Andersson

I have a weird problem. I write a XmlNode to a MemoryStream and the
data gets truncated at exactly 12k. The XmlNode and its children are
much larger than that but it always get cut at 12k.

Sample code:
Dim stream As New System.IO.MemoryStream
Dim writer As New XmlTextWriter(stream, Nothing)
myNode.WriteTo(writer)
writer = Nothing
stream.Position = 0
Debug.Write stream.Length

I can't see anything wrong in what I am doing...?
 
J

Jon Skeet [C# MVP]

Kristofer Andersson said:
I have a weird problem. I write a XmlNode to a MemoryStream and the
data gets truncated at exactly 12k. The XmlNode and its children are
much larger than that but it always get cut at 12k.

Sample code:
Dim stream As New System.IO.MemoryStream
Dim writer As New XmlTextWriter(stream, Nothing)
myNode.WriteTo(writer)
writer = Nothing
stream.Position = 0
Debug.Write stream.Length

I can't see anything wrong in what I am doing...?

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.
 
K

Kristofer Andersson

I have a weird problem. I write a XmlNode to a MemoryStream and the
data gets truncated at exactly 12k. The XmlNode and its children are
much larger than that but it always get cut at 12k.

Sample code:
Dim stream As New System.IO.MemoryStream
Dim writer As New XmlTextWriter(stream, Nothing)
myNode.WriteTo(writer)
writer = Nothing
stream.Position = 0
Debug.Write stream.Length

I can't see anything wrong in what I am doing...?

Found it - before releasing the XmlTextWriter I had to flush it using
writer.Flush().
 

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

Top