Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Smur for Serialize class to XML?

You need a stream and a XmlSerializer object, here's an example:

FileStream fs = new FileStream(@"C:\MyPath", FileMode.OpenOrCreate);xmlSerializer = new XmlSerializer(typeof(MyClass));xmlSerializer.Serialize(fs, myClassInstance);fs.Flush();fs.Close();fs.Dispose();

Don't forget to handle errors your own way. And I'm also assuming you want to serialize all your class' properties.


Viewing all articles
Browse latest Browse all 3

Trending Articles