Well, your problem most likely is that you're looking at the wrong file. Look at the config.FilePath
property in the debugger - it will tell you exactly which file you're dealing with here and now.
When you run this code in Visual Studio, your code will change the Yourapplication.exe.config
inside your project\bin\debug
directory - it will NOT change the app.config
in your project directory!
So when you run your code - after the config.Save()
, have a look at your project's \bin\debug
directory and the config file inside there - are those values properly updated?