Reputation: 127
I am able to create new application settings at runtime using this code :
SettingsProperty property = new SettingsProperty(sthing);
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(string);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(System.Configuration.UserScopedSettingAttribute), new
System.Configuration.UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
Properties.Settings.Default.Reload();
Properties.Settings.Default[sthing] = sthing;
Properties.Settings.Default.Save();
Is there something similar to delete a setting at runtime ? Something like :
Properties.Settings.Default["sthing"].Delete
Just to clarify : i don't want to clear the value of sthing
but i want to remove the entry named sthing
I am using Winforms
Upvotes: 2
Views: 1667
Reputation: 181
Try with:
Properties.Settings.Default.Properties.Remove(sthing);
Check here what you can do with Properties.Settings.Default.Properties
.
Upvotes: 3