The following methods can be used to persist an object (as long as it is serializable) to an XML file and then load it back in at another time.
public void SerializeObjectToXmlFile(string filePath, Type type, object data)
{
System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(type);
System.IO.TextWriter w = new System.IO.StreamWriter(filePath);
s.Serialize(w, data);
w.Close();
}
public T DeSerializeObjectFromXmlFile<T>(string filePath)
{
T result = default(T);
System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(T));
System.IO.TextReader r = new System.IO.StreamReader(filePath);
result = (T)s.Deserialize(r);
r.Close();
return result;
}
db884200-1c98-4c4f-ae1c-c8ef2a32aa0c|0|.0