Frank Du

Frank Du

  • NA
  • 1
  • 0

writing to a config file

Jan 6 2008 6:58 PM
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)