Users Pricing

forum

Home Forums assign textwriter to memory writer – MindStick

assign textwriter to memory writer

Anonymous User 2410 02 Sep 2014

I am writing xml file but missing some value for specific field. i check that when object comes which contains value that specific value exist but after writing xml value doesn't exist. following is the code which is using. I think XmlTextWriter could be the cause of wrong xml. There is another method which could be used for it that is TextWriter but failed to convert it into memorystream.

string xmlString = null;

            MemoryStream memoryStream = new MemoryStream();

            XmlSerializer xs = new XmlSerializer(typeof(T));

           // XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII);

            TextWriter xmlTextWriter=new StreamWriter(memoryStream,Encoding.ASCII);

            xs.Serialize(xmlTextWriter, obj);

            memoryStream =(MemoryStream)xmlTextWriter.   //(MemoryStream)xmlTextWriter.BaseStream;

            xmlString = ASCIIByteArrayToString(memoryStream.ToArray()); return `xmlString;`

Any idea how i can know why and where the problem occur.


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md