public void LoadSettings() { if (!File.Exists(@"scripts\SnipeMod\settings.xml")) { SaveSettings(); return; } Settings = new Settings(); using (var stream = new FileStream(@"scripts\SnipeMod\settings.xml", FileMode.Open)) Settings = (Settings)(new XmlSerializer(Settings.GetType()).Deserialize(stream)); }
public void SaveSettings() { Settings = new Settings(); Directory.CreateDirectory(@"scripts\SnipeMod"); using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { new XmlSerializer(Settings.GetType()).Serialize(writer, Settings); var xml = Encoding.UTF8.GetString(stream.ToArray()); File.WriteAllText(@"scripts\SnipeMod\settings.xml", xml); Log.Info(@"Saved settings to scripts\SnipeMod\settings.xml"); } } }
public void LoadSettings() { if (!File.Exists(@"scripts\SnipeMod\settings.xml")) { SaveSettings(); return; } Settings = new Settings(); using (var stream = new FileStream(@"scripts\SnipeMod\settings.xml", FileMode.Open)) Settings = (Settings) (new XmlSerializer(Settings.GetType()).Deserialize(stream)); }