title: .NET Exception Handling Application Configuration File
body: <p>I apologize as this question is somewhat basic; however, after a great deal of searching, I have not found a suitable answer.  I am building a windows forms application and need to reference an app.config file for the location to a data file.  Before calling </p>
  
  <pre><code>XElement xml = XElement.Load(ConfigurationManager.AppSettings["EntityData"].ToString());
  </code></pre>
  
  <p>I want to ensure that the app.config file exists.  I have tried multiple methods but it seems that it is a lot more work then it should be.  For example I have been trying to use the following code to determine the path for the file</p>
  
  <pre><code>        Uri uri = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
          string fullConfigurationFilename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(uri.AbsolutePath), configurationFilename);
  </code></pre>
  
  <p>but I run into issues with spaces in the path.  Is there a better way to check for the existence of the app.config, do I even need to check?</p>
  
  <p>Thank you</p>