I cant Save Appconfig key!!!
-
hi all, when m modifying appconfig key it just doesnt save it //my code System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["T"] != null) { config.AppSettings.Settings["T"].Value = "False"; //config.AppSettings.Settings.Remove("DatabaseServer"); } else { config.AppSettings.Settings.Add("Key1", "False"); } config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appSettings"); why is that happening !!!
-
hi all, when m modifying appconfig key it just doesnt save it //my code System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["T"] != null) { config.AppSettings.Settings["T"].Value = "False"; //config.AppSettings.Settings.Remove("DatabaseServer"); } else { config.AppSettings.Settings.Add("Key1", "False"); } config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appSettings"); why is that happening !!!
Because you can't modify data in the app.config programatically. If you want user-specific data to be saved, you have to use the
Settings
object."Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
hi all, when m modifying appconfig key it just doesnt save it //my code System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["T"] != null) { config.AppSettings.Settings["T"].Value = "False"; //config.AppSettings.Settings.Remove("DatabaseServer"); } else { config.AppSettings.Settings.Add("Key1", "False"); } config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appSettings"); why is that happening !!!
Your code works for me. If you're looking for changes in your App.config, you're not going to find them there. The changes are in the actual runtime configuration file named yourappname.exe.Config, which will be in the same folder as the exe. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: