public static void LoadCurrent() { try { string settingsPath = Locations.GetSaveConfigPath(GeneralSettings.AppName, true, "Settings.xml"); if (File.Exists(settingsPath)) { Current = XmlStorage.LoadXml <Settings>(settingsPath); Log.Info("Loaded settings from " + settingsPath); return; } } #region Error handling catch (IOException ex) { Log.Warn("Failed to load settings: " + ex.Message + "\nReverting to defaults"); } catch (UnauthorizedAccessException ex) { Log.Warn("Insufficient rights to load settings: " + ex.Message + "\nReverting to defaults"); } catch (InvalidDataException ex) { Log.Warn("Settings file damaged: " + ex.Message + "\nReverting to defaults"); } #endregion Log.Info("Loaded default settings"); Current = new Settings(); }
public static void SaveCurrent() { try { string settingsPath = Locations.GetSaveConfigPath(GeneralSettings.AppName, true, "Settings.xml"); Current.SaveXml(settingsPath); Log.Info("Saved settings to " + settingsPath); } #region Error handling catch (IOException ex) { Log.Warn("Failed to save settings: " + ex.Message); } catch (UnauthorizedAccessException ex) { Log.Warn("Insufficient rights to save settings: " + ex.Message); } #endregion }