Application path in vs2005 c#

Hi,
how to retreive appication path in vs2005 c#?
thanks
bobdylan75Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
roberto12crConnect With a Mentor Commented:
Try this:  Environment.CurrentDirectory
0
 
buraksaricaConnect With a Mentor Commented:
You can use :

string a = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

Open in new window

0
 
Fernando SotoConnect With a Mentor RetiredCommented:

String appPath = Application.StartupPath;
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
bobdylan75Author Commented:
sorry, perhaps I explain wrong..
Is this the path of my c# application opened?
0
 
Fernando SotoRetiredCommented:
It is the path to where the executable is located in the system.
0
 
bobdylan75Author Commented:
FernandoSoto have I to add some "using" statement to call Application oblect?
0
 
Fernando SotoRetiredCommented:
It is in System.Windows.Forms namespace and should be there by default on a Windows Form application.
0
 
ajb2222Commented:
if you want the path to the actual executable file with the executable name you use  Application.ExecutablePath

if you only want the path to the executable you would use Application.StartupPath.  
0
 
buraksaricaConnect With a Mentor Commented:
AppDomain.CurrentDomain.SetupInformation.ApplicationBase is the best solution, also for the debugging purposes.
0
 
bobdylan75Author Commented:
sorry but the only solutuion that works is the roberto12cr's one.
parhaps due to my app isn't a windows app but only a console app??
0
 
Fernando SotoRetiredCommented:
Be careful not to change the current working directory in your program because if you do it will no longer point to where the executable is running from.
0
All Courses

From novice to tech pro — start learning today.