Executable's path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

With .net2, how do I get the path of where the .EXE is located for a WinForms
app? e.g. for "h:\myapps\testapp\test.exe" , "h:\myapps\testapp\" should
bee returned
 
c#

using System.IO;
using System.Reflection;

....

string pathDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);

or if you're really looking for the current directory...

string pathDir = System.Environment.CurrentDirectory;
 
Back
Top