I am creating an XML file through the XmlTextWriter. This is output to a
MemoryStream which I convert a string through a Byte Array. Everything works
correctly except for one BIG issue. My XML file is being truncated somewhere
in the process. Large XML files give a truncated result, and small ones rsult
in a Byte[].Length = 0 .
I assume the it is getting stuck in a buffer??
I tried Fluch() on the MemStream and Base Stream without success.
Code Fragment:
MemoryStream memStream = new MemoryStream();
xmlw = new XmlTextWriter(memStream,Encoding.UTF8);
//
//Code that creates the XML Document
//xmlw.BaseStream.Flush();
//memStream.Flush();
memStream.Position = 0;
Byte[] info = new byte[memStream.Length];
int li = memStream.Read(info,0,(int)memStream.Length);
int lo = info.Length;
return new System.Text.UTF8Encoding().GetString(info,0,info.L ength);