How to determine current EXE directory for a C# console application

3
=
0
+
3
3 Bitcoin bounty has been announced by author.
0 has been already awarded by author.
3 remains available.
1

I tried to determine current running directory of my C# console application using the following code:

Assembly.GetExecutingAssembly().Location

However that code returns path to assembly location. It may be different from the folder where EXE file is located.

My console application parses logs with no parameters. I want to know the path to the logs/ folder inside of the current executable's folder. Please help!

Tags: , ,

3 answers

3
=
1
=
$0.5
1 tip with total amount of 2 mBTC($0.5 USD) have been sent by alexander.kojemyakin

In the ASP.NET. Have you ever wanted to get the directory for the executing Console Application in C#? The following method will do so, and is the equivalent of Application.StartupPath when working with Windows Forms.

System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
SEND BITCOIN TIPS
User rating:

Thanks, here is my tip!

User rating:

Here is another tip

0

You can use following method:

System.Reflection.Assembly.GetExecutingAssembly().Location
SEND BITCOIN TIPS
User rating:

Thank you

0

Hi

you can use "Directory.GetCurrentDirectory" to get the current working directory of the application.

SEND BITCOIN TIPS
0

Too many commands? Learning new syntax?

FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with FavScripts.com!

Post Answer