title: C#: Directory.getCurrentDirectory() when launching from Browser
body: <p>I'm currently working on an Autoupdater for my Applications. (combined with an installer, updater and removal tool)</p>
  
  <p>I'd like to setup all the Stuff automatically:</p>
  
  <ul>
  <li>Startmenu Entry</li>
  <li>Folder in C:\Program Files\</li>
  <li>Config Folder in App Data (depending on Roaming / local)</li>
  <li>Software Removal-Entry in "Programs &amp; Features"</li>
  <li>Desktop Shortcut.</li>
  </ul>
  
  <p>This works all very well. For writing to Program Files and the registry the tool needs Administrator privilegs ofc. So I added a "restart" of the AppLauncher, after the desired software has been picked.
  Just something like this:</p>
  
  <pre><code>ProcessStartInfo pi = new ProcessStartInfo(Directory.GetCurrentDirectory() + @"\AppLauncher.exe");
          pi.Verb = "runas";
          pi.Arguments = "install " + this.appItem.APID;
  
          Process p = new Process();
          p.StartInfo = pi;
          try
          {
              p.Start();
              Application application = Application.Current;
              application.Shutdown();
          }
          catch (Exception ex)
          {
              MessageBox.Show("Unable to install the application.\n\n" + ex.ToString(), "Error", 
              application.Shutdown();
          }
  </code></pre>
  
  <p>Also this step works very well, <strong>if</strong> the User saves the AppLauncher.exe somewhere in a Folder and starts it by double clicking it. </p>
  
  <p>If a User decides to hit "run" from the Browser, The installer runs into the shown exception, saying "AppLauncher.exe" not found. I Assume, that starting the File right from the browser will setup a different WorkingDirectory and therefore</p>
  
  <pre><code>Directory.GetCurrentDirectory()
  </code></pre>
  
  <p>will not return the appropriate value, where the file is located.
  It may also NOT work, if the user decides to give the file another name.</p>
  
  <p>So, what can I do on this? </p>
  
  <p>Is there something like File.GetCurrentFile() :P</p>