title: Trying to open another's application configuration file
body: <p>I'm developing a WinForm application with C# and .NET Framework 4.7.</p>
  
  <p>With this application I'm trying to load the configuration file from another application:</p>
  
  <pre><code>string applicationName = Environment.GetCommandLineArgs()[1];
  
  if (!string.IsNullOrWhiteSpace(applicationName))
  {
      if (!applicationName.EndsWith(".exe"))
          applicationName += ".exe";
  
      string exePath = 
          Path.Combine(Environment.CurrentDirectory, applicationName);
  
      try
      {
          // Get the configuration file. The file name has
          // this format appname.exe.config.
          System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(exePath);
  </code></pre>
  
  <p>But <code>ConfigurationManager.OpenExeConfiguration(exePath)</code> throw an exception:</p>
  
  <pre><code>An error occurred while loading the configuration file: The 'exePath' parameter is not valid.
  Parameter name: exePath
  </code></pre>
  
  <p>The configuration file, AnotherApp.exe.config, exists in the folder <code>Environment.CurrentDirectory</code>. I have also tried changing it to <code>Path.Combine(@"D:\", applicationName);</code> and I get the same exception.</p>
  
  <p>If I add the <code>exe.config</code>, instead of <code>.exe</code>, at the end of the name here, <code>applicationName += ".exe";</code>, it seems to open something: <code>config.FilePath</code> is <code>D:\AnotherApp.exe.config.config</code>. But <code>config</code> object is empty. It hasn't filled any property.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>I have copied the code from <a href="https://docs.microsoft.com/es-es/dotnet/api/system.configuration.configurationmanager.openexeconfiguration?view=netframework-4.7.1#System_Configuration_ConfigurationManager_OpenExeConfiguration_System_String_" rel="nofollow noreferrer">Microsoft documentation</a>.</p>