1
Answer

writing to a config file

Frank Du

Frank Du

16y
2.2k
1
Hello,

I copied this code from MS web site trying to add a new key to current config file, but it does not save the config file at all when my app exits, any idea?

    // Open App.Config of executable
                System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
               
                config.AppSettings.Settings.Add("TestKey", "gdhgasdkjadhsj");
                // Save the configuration file.
                config.Save(ConfigurationSaveMode.Full);

How could this code have no exceptions whatsoever but just not doing what Microsoft claim it should do -- save the damn config file?

Answers (1)