Simba White

Simba White

  • NA
  • 32
  • 8k

Save method is not working on New Setting Property

Feb 2 2017 2:12 PM

I have a big project with many sub projects. For a specific sub project, I want to create user settings at run time.

I have initialized the settings file with one dummy Setting.

Why the settings are not getting saved into the Settings file ?

Some articles suggest to Set User-Scope ? I have no idea how to do that.

Thank you

 
  1. try    
  2. {      
  3.     if (!string.IsNullOrEmpty(Properties.Settings.Default["mySetting"].ToString()))      
  4.     {  
  5.         //Do something here  
  6.     }      
  7. }  
  8. catch (Exception)  
  9. {  
  10.     SettingsProperty AProperty = new SettingsProperty("mySetting");  
  11.   
  12.     AProperty.PropertyType = typeof(bool);  
  13.     AProperty.IsReadOnly = false;  
  14.     AProperty.DefaultValue = false;  
  15.     Properties.Settings.Default.Properties.Add(AProperty);  
  16.     Properties.Settings.Default.Save();  
  17.     Properties.Settings.Default.Reload();  
  18. }   

Answers (5)