xmlnode.writeto > memorystream gets truncated

  • Thread starter Thread starter Kristofer Andersson
  • Start date 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...?
 
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.
 
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().
 
Back
Top