title: "Access to path denied" issue
body: <p>1) i was trying to create directory programmatically this way</p>
  
  <pre><code>if (!Directory.Exists(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\VoiceRecords"))
      {
  Directory.CreateDirectory(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\VoiceRecords");
      }
  </code></pre>
  
  <p>the above code works fine when i run my apps in debug mode but after creating setup and when i installed then when the above line execute and try to create folder in my apps installation location then problem start. what would be the best approach to get rid of this prob because i will distribute this setup to 3rd part and they can install my apps any where which i may not know.</p>
  
  <p>2) when i try to save any value in app.config file then i am getting error.
  the error screen shot is here.
  <img src="https://i.stack.imgur.com/oK8Kl.png" alt="enter image description here"></p>
  
  <p>now i like to show how i am write data to config at runtime</p>
  
  <pre><code>Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                          if (config.AppSettings.Settings["localVoiceRecordsPath"].Value != null || config.AppSettings.Settings["localVoiceRecordsPath"].Value.Trim() != "")
                          {
  
                              config.AppSettings.Settings["localVoiceRecordsPath"].Value = SettingsPopup.txtPath.Text.Replace(",", string.Empty);
                              config.Save(ConfigurationSaveMode.Modified);
                              SettingsPopup.txtPath.Text = config.AppSettings.Settings["localVoiceRecordsPath"].Value.Replace(",", string.Empty);
                          }
                          else
                          {
                              config.AppSettings.Settings.Add("localVoiceRecordsPath", SettingsPopup.txtPath.Text.Replace(",", string.Empty));
                              config.Save(ConfigurationSaveMode.Modified);
                              SettingsPopup.txtPath.Text = config.AppSettings.Settings["localVoiceRecordsPath"].Value.Replace(",", string.Empty);
                          }
  </code></pre>
  
  <p>everything is working fine when i run my apps in debug mode but problem start when i install the apps from setup and then run. i guess some kind of permission related problem occur. looking for best guidance. thanks</p>
  
  <h2>EDIT</h2>
  
  <p>Problem solved. i run my apps programmatically in admin mode this way</p>
  
  <pre><code>static bool IsRunAsAdmin()
          {
              WindowsIdentity id = WindowsIdentity.GetCurrent();
              WindowsPrincipal principal = new WindowsPrincipal(id);
              return principal.IsInRole(WindowsBuiltInRole.Administrator);
          }
  
          /// &lt;summary&gt;
          /// The main entry point for the application.
          /// &lt;/summary&gt;
          [STAThread]
          static void Main()
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              if (Environment.OSVersion.Version.Major &gt;= 6)
              {
                  if (!IsRunAsAdmin())
                  {
                      ProcessStartInfo proc = new ProcessStartInfo();
                      proc.UseShellExecute = true;
                      proc.WorkingDirectory = Environment.CurrentDirectory;
                      proc.FileName = Application.ExecutablePath;
                      proc.Verb = "runas";
  
                      try
                      {
                          Process.Start(proc);
                      }
                      catch
                      {
                          // The user refused the elevation.
                          // Do nothing and return directly ...
                          return;
                      }
  
                      Application.Exit();  // Quit itself
                  }
                  else
                  {
                      Application.Run(new frmMain());
                  }
              }
              else
              {
                  Application.Run(new frmMain());
              }
          }
  </code></pre>