console application path

How would I get the path of a console application?  Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() works for a web app, but how about for a console app?
arichexeAsked:
Who is Participating?
 
smeggheadCommented:
use

System.IO.Directory.GetCurrentDirectory()

0
 
Mikal613Commented:
string aPath1 = Application.ExecutablePath;
    string aPath2 = Application.StartupPath
0
 
ennixoCommented:
1. Add a reference to System.Windows.Forms
2. Add a using System.Windows.Forms; statement
3. The path you need is in Application.StartupPath property
0
 
ennixoCommented:
Bad choice...

create a shortcut to your executable, edit the properties of this shortcut to change the startup path and then run your program : GetCurrentDirectory won't return the good path.

It may also return a wrong path if you access to files and change the current directory (ie: with SetCurrentDirectory) and then call GetCurrentDirectory.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.