title: Check for the .config file in the right folder
body: <p>I have made a program in C# that reads text files (.nfo files) when I open the nfo file. (Associated .nfo files with my exe file).</p>
  
  <p>The program checks for a config file, and if it's missing, it creates a new one. </p>
  
  <p>This works fine if I run the exe file manualy, and then open an nfo file from inside the program. When I double click an nfo file, the program starts, but allso writes a config file in the same folder as the nfo file.</p>
  
  <p>I want the program to ONLY check for config file in the same folder as the exe file. I want the exe file to be folder independent too. </p>
  
  <p>Here's the code for the config check / write:</p>
  
  <pre><code>string configFil = "XnfoReader.exe.Config";
  StreamWriter sw = null;
  string configText = @"&lt;?xml version=""1.0"" encoding=""utf-8"" ?&gt;"
  
  if (!File.Exists(configFil))
  {
      FileStream fs = File.Open(configFil, FileMode.CreateNew, FileAccess.Write);
      sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
      sw.WriteLine(configText);
      sw.Close();
      sw = null;
  }
  </code></pre>
  
  <p>Am I making sense here? </p>