I'm using an XmlTextWriter and it's various methods such as
WriteElementStr ing, WriteStartEleme nt, WriteEndElement , etc to create an xml
document. When I instantiate the XmlTextWriter to a file...
XmlTextWriter mytw = new XmlTextWriter(" c:\\temp\\myfil e.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(my MemoryStream);
XmlTextWriter mytw = new XmlTextWriter(m yStreamWriter);
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