c# replace file stream with string
Posted on 2010-08-12
I am trying to convert some code that writes to a file to return a string.
how do I get rid of the part where I write to a file and just return a string?
public static void XMLSerializeClass(object classToSerialize, string fileNameToWriteTo)
// Initialize a storage medium to hold the serialized object
Stream stream = new FileStream(fileNameToWriteTo, FileMode.Create, FileAccess.Write, FileShare.Write);
// Serialize an object into the storage medium referenced by 'stream' object.
XmlSerializer xmlserializer = new XmlSerializer(classToSerialize.GetType());