title: C#: Read and modify settings in another application's app.config file
body: <p>I have a number of applications running which communicate with each other but none of these applications have their own user interface.  I have a system console application which acts as a user interface for the system (i.e. the set of applications which all talk to each other).  </p>
  
  <p>I would like to be able to use the system console to read and modify the configuration of each of the non-gui apps.<br>
  Each app has an app.config file created using the Visual Studio Settings GUI.  The settings are all in application scope, which results in an app.config file which looks a bit like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
  &lt;configSections&gt;
      &lt;sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt;
          &lt;section name="ExternalConfigReceiver.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
  &lt;/configSections&gt;
  &lt;applicationSettings&gt;
      &lt;ExternalConfigReceiver.Properties.Settings&gt;
          &lt;setting name="Conf1" serializeAs="String"&gt;
              &lt;value&gt;3&lt;/value&gt;
          &lt;/setting&gt;
          &lt;setting name="Conf2" serializeAs="String"&gt;
              &lt;value&gt;4&lt;/value&gt;
          &lt;/setting&gt;
      &lt;/ExternalConfigReceiver.Properties.Settings&gt;
  &lt;/applicationSettings&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have tried using the following code to read the configuration settings:</p>
  
  <pre><code>System.Configuration.ExeConfigurationFileMap fileMap = new   System.Configuration.ExeConfigurationFileMap();
  fileMap.ExeConfigFilename = "PATH_TO_THE_FOLDER\\app.config";
  
  System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(fileMap, System.Configuration.ConfigurationUserLevel.None);
  
  someVariable =  config.AppSettings.Settings["Conf1"];
  someVariable2 = config.AppSettings.Settings["Conf2"];
  </code></pre>
  
  <p>However on closer inspection of the config.AppSettings object, I find that it contains no settings.</p>
  
  <p>What am I doing wrong?  Am I using the wrong method to read the config file?  Is this method best for a different sort of config file?</p>