There is a way to reset application settings with Settings.Default.Reset()
Is there a way to reset only one property? Something like
Settings.Default.Properties["MyPropertyName"].Reset();
You can use the Settings.Default.Properties["MyProperty"].DefaultValue
to obtain the default value for the property, and set the property value to that.
It's the PropertyValue
that's need to be set in combinaison of Deserialized
(the order matter) :
public void ResetOneSetting(string propertyName)
{
SettingsPropertyValue propertyToReset = Settings.Default.PropertyValues.OfType<SettingsPropertyValue>().FirstOrDefault(p => p.Name == propertyName);
if (propertyToReset != null)
{
propertyToReset.PropertyValue = propertyToReset.Property.DefaultValue;
propertyToReset.Deserialized = false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With