C# Programming
05-13-2010, 04:11 PM
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
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