I am using some Microsoft examples that:
1. Serialize an object using XmlSerializer and write a file out to the
harddrive.
2. Read back in the file using XmlDocument.Load and populate a string.
What I would like to do is use MemoryStream to do this instead of writing
to the harddrive, but I am lost in the readers, writers etc.
Can someone show me how to to this using a memory stream.
thanks
grs
// Code to accept eConnectType object and write to a disk file
public void WriteObjectsToFile(string fileName,eConnectType
objectToSerialize)
{
try
{
XmlSerializer xmlSerializer = new
XmlSerializer(objectToSerialize.GetType());
XmlTextWriter xmlTextWriter = new XmlTextWriter(fileName,null);
xmlSerializer.Serialize(xmlTextWriter,objectToSeri alize);
xmlTextWriter.Close();
}
// code reading the file and creating the string.
string aXmlString;
try
{
// Load the written xml document
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(fileName);
aXmlString = xmlDocument.OuterXml;