arichexe
asked on
console application path
How would I get the path of a console application? Request.ServerVariables["A PPL_PHYSIC AL_PATH"]. ToString() works for a web app, but how about for a console app?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
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.
string aPath2 = Application.StartupPath