Save "app.config" configuration-file does not work
-
Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works
static void Main(string\[\] args) { // Open App.Config of executable Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add a new Application Setting. config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " "); // This does not update the file "app.config" config.Save(ConfigurationSaveMode.Full); // This correctly writes the file "Test.config" config.SaveAs("Test.config", ConfigurationSaveMode.Full); }
Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance
-
Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works
static void Main(string\[\] args) { // Open App.Config of executable Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add a new Application Setting. config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " "); // This does not update the file "app.config" config.Save(ConfigurationSaveMode.Full); // This correctly writes the file "Test.config" config.SaveAs("Test.config", ConfigurationSaveMode.Full); }
Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance
Is it throwing any error?Can you check if the file is readonly
Arun Jacob http://codepronet.blogspot.com/
-
Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works
static void Main(string\[\] args) { // Open App.Config of executable Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add a new Application Setting. config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " "); // This does not update the file "app.config" config.Save(ConfigurationSaveMode.Full); // This correctly writes the file "Test.config" config.SaveAs("Test.config", ConfigurationSaveMode.Full); }
Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance
The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config
-
Is it throwing any error?Can you check if the file is readonly
Arun Jacob http://codepronet.blogspot.com/
-
The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config
Sorry, of course, app.config is not expected to be updated, but I expect that in the bin-directory one of the files ".xx.exe.config" or "xx.vshost.exe.Config" should be updated at least. But none of them is updated. I', puzzled. What's the purpuse of the Save()-Method? Thanks for you kind replies