public static TextDemoSettings RecallSettings() { TextDemoSettings settings = new TextDemoSettings(); string applDataDir = TextDemoSettings.BuildApplDataDir(); Pather.AssureDirectoryExists(applDataDir); string applStateFileName = "TextDemoSettings.xml"; string applStatePath = Path.Combine(applDataDir, applStateFileName); if (File.Exists(applStatePath) == true) { try { using (XmlTextReader tr = new XmlTextReader(applStatePath)) { settings.ReadXml(tr); } } catch (Exception) { settings = new TextDemoSettings(); } } return(settings); }
public void StoreSettings() { string applDataDir = TextDemoSettings.BuildApplDataDir(); string applStateFileName = "TextDemoSettings.xml"; string applStatePath = Path.Combine(applDataDir, applStateFileName); using (StreamWriter stmw = new StreamWriter(applStatePath)) { XmlSerializer xmlser = new XmlSerializer(typeof(TextDemoSettings)); xmlser.Serialize(stmw, this); } }
/// <summary> /// check that settings exist for the appl. /// </summary> /// <returns></returns> public static bool SettingsExist() { TextDemoSettings settings = new TextDemoSettings(); string applDataDir = TextDemoSettings.BuildApplDataDir(); Pather.AssureDirectoryExists(applDataDir); string applStateFileName = "TextDemoSettings.xml"; string applStatePath = Path.Combine(applDataDir, applStateFileName); if (File.Exists(applStatePath) == true) { return(true); } else { return(false); } }