Link to home
Start Free TrialLog in
Avatar of arichexe
arichexe

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mikal613
string aPath1 = Application.ExecutablePath;
    string aPath2 = Application.StartupPath
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
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.