public static void SaveToFile(string filename, RomSettings settings) { if (File.Exists(filename)) { File.Delete(filename); } using (FileStream stream = new FileStream(filename, FileMode.CreateNew)) { XmlSerializer ser = new XmlSerializer(typeof(RomSettings)); ser.Serialize(stream, settings); } }
public static RomSettings ReadFromFile(string filename) { RomSettings result = new RomSettings(); if (File.Exists(filename)) { using (FileStream stream = new FileStream(filename, FileMode.Open)) { XmlSerializer ser = new XmlSerializer(typeof(RomSettings)); result = (RomSettings)ser.Deserialize(stream); } } return(result); }