I have a custom .config
file which is below and wanted to read value of ServerUrl
and update it. I can go till AutoUpdate
but not sure how can I go to Settings -> ServerUrl
.
.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="AutoUpdate">
<section name="Settings" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>
<AutoUpdate>
<Settings>
<add key="Enabled" value="True" />
<add key="ForceActivation" value="True" />
<add key="Environment" value="Prod" />
<add key="ServerUrl" value="https://Something.xml" />
<add key="HourToCheckAutoUpdate" value="1" />
</Settings>
</AutoUpdate>
</configuration>
Code:
var configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = @"MyPath\My.config";
var config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);
var b = config.GetSectionGroup("AutoUpdate"); // This returns "AutoUpdate".