المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Any way to add USER settings at runtime?



C# Programming
12-20-2011, 02:20 AM
Has anybody found a way to add a user setting at runtime? I know its not really designed for that, but I'm trying to automate the upgrade process in my app and need to add a setting. I know I am allowed to add app settings and could use those in a more complicated way, but I'd really like to do it with the user settings since the way those work will do half my job for me http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif .

Tried doing something like:

b.Properties.Add(new SettingsProperty("Testing", typeof(string), null, false, null, SettingsSerializeAs.String, null, false, false));
b.PropertyValues.Add(new SettingsPropertyValue(new SettingsProperty("Testing")));
b.PropertyValues["Testing"].PropertyValue = "Blah";

but it doesn't get written out and when I iterate through the props, I get an exception in .Net. I don't really care if the property shows up in the designer.