public static void Save(string path, ViewSettings vs) { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(vs.GetType()); using (System.IO.StreamWriter s = new System.IO.StreamWriter(path)) { xs.Serialize(s, vs); } }
public static ViewSettings Load(string path) { ViewSettings vs = new ViewSettings(true); if (System.IO.File.Exists(path)) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(vs.GetType()); using (System.IO.StreamReader s = new System.IO.StreamReader(path)) { vs = (ViewSettings)xs.Deserialize(s); return(vs); } } else { return(null); } }