Configuration file wirter?

goodmorningsky

Centurion
Joined
Aug 18, 2003
Messages
172
I can read Configuration file using
AppSettingsReader.GetValue(key, type);

But, I want to write value corresponding the key.
I counldn't find method like
AppSettingsWriter.WriteValue(key, type);

How can I do this? Is there api doning this?
 
Great question!
Although I think you wrote this during the 1.0 or 1.1 days 2.0 is supposed to simplify this process.

Acoording to msdn you can do the following:

Code:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings["mySetting"].Value = "myNewValue";
                config.Save(ConfigurationSaveMode.Modified,true);
                ConfigurationManager.RefreshSection("appSettings");

But I have no luck with this. No errors, just no writing to the config file.
I am in VS05 writing a 2.0 win form application.

Any suggestions?
 
It looks like you guys are using C# so my advice won't be very helpful...but if you were using VB8, I'd tell you to check out the My namespace.
 
Back
Top