Serialization allows you to do this - it's actually how objects are sent across a web-service.
If you're lucky, the following code will serialise an object (called "object" of type "object_type".)
XmlSerializer serialiser = new XmlSerializer(typeof(object_type));
FileStream stream = new FileStream(@"C:\Temp\serialised_file.xml", FileMode.Create);
serialiser.Serialize(object, stream);
And to de-serialise:
XmlSerializer serialiser = new XmlSerializer(typeof(object_type));
FileStream stream = new FileStream(@"C:\Temp\serialised_file.xml", FileMode.Open);
object_type object = serialiser.Deserialize(stream) as object_type;
I say "if you're lucky" because 90% of the time that works for me. If you have properties within the class that are abstract classes you may need to declare all class types that extend that abstract class in the XmlSerializer
constructor. Also be careful there are no "circular dependencies" within the class.