I have the following code to change key value in Web.config
file.
Configuration webConfigApp = WebConfigurationManager.OpenWebConfiguration("~");
webConfigApp.AppSettings.Settings["Email"].Value = "abc@def.com";
webConfigApp.Save();
It changes the value successfully but it also affects the file structure. I have some comments in the file that comments are gone after running the above code.
Is there any code which only updates the key value and not affects the entire file?