How to get current directory of .exe in C#

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

How do you get the current directory of the actual .exe file (not the file
name but the directory it is in) ?

These do not work:
System.IO.Directory.GetCurrentDirectory() - returns system directory not
current directory of .exe
System.Environment.CurrentDirectory - returns system directory not current
directory of .exe
System.Reflection.Assembly.GetExecutingAssembly().Location - returns the
file name of the current binary

Is there any method that just returns the directory that the current binary
is running in?
 
This works in C# for Smart Device Projects ( PPC 2002 ), as the CF does not
seem to support Application.StartUp.

Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
 
Back
Top