How to get execution directory of console application
Use Environment.CurrentDirectory
.
Gets or sets the fully qualified path of the current working directory.
(MSDN Environment.CurrentDirectory Property)
string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs");
If your application is running in c:\Foo\Bar logsDirectory
will point to c:\Foo\Bar\logs.
Use this :
System.Reflection.Assembly.GetExecutingAssembly().Location
Combine that with
System.IO.Path.GetDirectoryName if all you want is the directory.
Safest way:
string temp = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);