I'm using an XmlTextWriter and it's various methods such as
WriteElementString, WriteStartElement, WriteEndElement, etc to create an xml
document. When I instantiate the XmlTextWriter to a file...
XmlTextWriter mytw = new XmlTextWriter("c:\\temp\\myfile.xml", null)
Everything writes properly and a good XML document gets created.
However if I instantiate the XmlTextWriter to a memoryStream...
Stream myMemoryStream = new MemoryStream();
TextWriter myStreamWriter = new StreamWriter(myMemoryStream);
XmlTextWriter mytw = new XmlTextWriter(myStreamWriter);
and then examine myMemoryStream, the last endelement</mydocdoes not get
written and after a mytw.Flush() it still isn't written. Then after a
mytw.Close() the mytw.basestream and myMemoryStream are null.
So writing to a file is successful because the end tag gets written to disk,
apparently by the Close() that also nulls the stream.
So, how can I get that last tag written and have access to the stream before
it is destroyed?
--
Regards,
Gary Blakely