/// <summary> /// Saves the provided settings to the XML file. /// </summary> /// <param name="settings">The settings to save.</param> public static void SaveSettings(CityVitalsWatchSettings settings) { StreamWriter stream = null; try { XmlSerializer serializer = new XmlSerializer(typeof(CityVitalsWatchSettings)); stream = new StreamWriter(SettingsFileName); serializer.Serialize(stream, settings); } catch { // Do nothing on exception } finally { if (stream != null) { stream.Close(); } } }
/// <summary> /// Loads the settings from the XML file. /// </summary> /// <returns>The loaded settings.</returns> public static CityVitalsWatchSettings LoadSettings() { CityVitalsWatchSettings settings = null; FileStream stream = null; try { XmlSerializer serializer = new XmlSerializer(typeof(CityVitalsWatchSettings)); stream = new FileStream(SettingsFileName, FileMode.Open); settings = (CityVitalsWatchSettings)serializer.Deserialize(stream); } catch { settings = new CityVitalsWatchSettings(); } finally { if (stream != null) { stream.Close(); } } return settings; }
/// <summary> /// Loads the settings from the XML file. /// </summary> /// <returns>The loaded settings.</returns> public static CityVitalsWatchSettings LoadSettings() { CityVitalsWatchSettings settings = null; FileStream stream = null; try { XmlSerializer serializer = new XmlSerializer(typeof(CityVitalsWatchSettings)); stream = new FileStream(SettingsFileName, FileMode.Open); settings = (CityVitalsWatchSettings)serializer.Deserialize(stream); } catch { settings = new CityVitalsWatchSettings(); } finally { if (stream != null) { stream.Close(); } } return(settings); }