Esempio n. 1
0
 public static void SaveSettings()
 {
     try
     {
         XmlSerializer xmlSerializer = new XmlSerializer(LocalSettings._settingsObject.GetType());
         XmlTextWriter xmlTextWriter = new XmlTextWriter(LocalSettings.SettingsFileName, null);
         try
         {
             xmlSerializer.Serialize(xmlTextWriter, LocalSettings._settingsObject);
         }
         finally
         {
             xmlTextWriter.Close();
         }
     }
     catch (UnauthorizedAccessException)
     {
         if (!File.Exists(LocalSettings.UserSettingsFileName))
         {
             File.Create(LocalSettings.UserSettingsFileName).Close();
             LocalSettings.SaveSettings();
         }
     }
     catch (IOException)
     {
     }
 }
Esempio n. 2
0
 public static void UpdateSetting(string settingName, string settingValue)
 {
     LocalSettings._settingsObject.SetCustomValue(settingName, settingValue);
     LocalSettings.SaveSettings();
 }