c# - How to add new property to settings -
"that's been asked thousand times" you'll , may right, none of answers either covers problem or doesn't work. here's question 1001 : method below called, when specific property doesn't exist. in case property should created default value , added settings. property correctly added, settins.save() doesn't work. long application running property exists when application closed , restartet property missing;
private void createnewproperty(string _property, object _value) { applicationsettingsbase settings = #######.properties.settings.default settingsproperty property = new settingsproperty(_property); property.defaultvalue = _value; property.isreadonly = false; property.propertytype = _value.gettype(); property.provider = osettings.providers["localfilesettingsprovider"]; property.attributes.add(typeof(system.configuration.userscopedsettingattribute), new system.configuration.userscopedsettingattribute()); settings.properties.add(property); settings.reload(); _value = settings[_property].tostring(); settings.save();
}
'#######' namespace of application amin window
so code above more or less equal solutions i've found far missing here ? in advance franz
Comments
Post a Comment