Solved

Application path in vs2005 c#

Posted on 2010-11-22
11
671 Views
Last Modified: 2013-12-17
Hi,
how to retreive appication path in vs2005 c#?
thanks
0
Comment
Question by:bobdylan75
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 5

Assisted Solution

by:buraksarica
buraksarica earned 66 total points
ID: 34188108
You can use :

string a = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

Open in new window

0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 33 total points
ID: 34188138

String appPath = Application.StartupPath;
0
 

Author Comment

by:bobdylan75
ID: 34188145
sorry, perhaps I explain wrong..
Is this the path of my c# application opened?
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34188174
It is the path to where the executable is located in the system.
0
 

Author Comment

by:bobdylan75
ID: 34188176
FernandoSoto have I to add some "using" statement to call Application oblect?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34188210
It is in System.Windows.Forms namespace and should be there by default on a Windows Form application.
0
 
LVL 6

Expert Comment

by:ajb2222
ID: 34188247
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
 
LVL 5

Assisted Solution

by:buraksarica
buraksarica earned 66 total points
ID: 34188289
AppDomain.CurrentDomain.SetupInformation.ApplicationBase is the best solution, also for the debugging purposes.
0
 

Accepted Solution

by:
roberto12cr earned 401 total points
ID: 34188298
Try this:  Environment.CurrentDirectory
0
 

Author Comment

by:bobdylan75
ID: 34192374
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
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 34193633
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now