I have a configuration file like this:
<configSections>
<section
name="environmentVariables"
type="System.Configuration.NameValueFileSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=234effdfsdfdf" />
</configSections>
<environmentVariables>
<add key="xxx" value="yyyy" />
<add key="zz" value="ddd" />
</environmentVariables>
I need to change the values of key "xxx" and "zz" during runtime from C#.
I have accessed the file using the code below:
string configPath = HttpContext.Server.MapPath("~/files/temp.config");
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configPath;
System.Configuration.Configuration config =
ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);