Hi Cindy,
> I want to serialize an object into the memory buffer instead of into a file.
> How do I do that?
>
> All the examples I have seen are serializing into a file. In my case, I
> don't have access to the hard disk. Can I serialize into the memory directly
> using XmlSerializer?
using System.Xml;
using System.Xml.Serialization;
...
public static string XmlSerializeToString(object data)
{
StringBuilder b = new StringBuilder();
XmlSerializer x = new XmlSerializer(data.GetType());
TextWriter w = new StringWriter(b);
x.Serialize(w, data);
w.Close();
return b.ToString();
}
bye
Rob
Cindy Liu - 07 Oct 2004 19:49 GMT
This is what I want! I found another way using MemoryStream. But your way is
the best!
Thanks!!!!!
Cindy
> Hi Cindy,
>
[quoted text clipped - 21 lines]
> bye
> Rob
agulko@pobox.com - 25 Oct 2004 18:25 GMT
Based on your example - how would I de-seralize from a string to an object ?