Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out what directory my console app is running in?

How do I find out what directory my console app is running in with C#?

like image 685
John Sheehan Avatar asked Sep 18 '08 21:09

John Sheehan


People also ask

How do I close the console application?

Exit a Console Application With the return Method in C# The return statement ends the execution of a method and returns the control to the calling or the main method. We can use the return statement inside the main() function to end our console application's execution.

How do I get the console app in Visual Studio?

Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.


1 Answers

To get the directory where the .exe file is:

AppDomain.CurrentDomain.BaseDirectory 

To get the current directory:

Environment.CurrentDirectory 
like image 85
Hallgrim Avatar answered Sep 18 '22 20:09

Hallgrim