Solved

how can i get directory path in C#.net window application ??

Posted on 2011-02-23
5
606 Views
Last Modified: 2012-05-11
currently i m working on C#.net windows application ....
i want to know that how can i get directory path in C#.net window application ??

for ex ...

C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Question_Assistant\Question_Assistant

now how can i get the above path using command ??
0
Comment
Question by:Parth48
5 Comments
 
LVL 11

Expert Comment

by:DeepuAbrahamK
ID: 34960219
Try this:

String name = System.Windows.Forms.Application.ExecutablePath;
0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 34960319
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34960326
Application.StartupPath is the path your exe is running from.
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 34960466
Hi,
Application.ExecutablePath will get the path for the executable file that started the application, including the executable name.  
Application.StartupPath will get the path of the executable file that started the application, not including the executable name.
0
 
LVL 11

Accepted Solution

by:
Sudhakar Pulivarthi earned 500 total points
ID: 34960497
Hi,
When exe1 calls exe2 then in exe2 when we try to get in the above way using Application we will get the exe1 path information not the exe2.
To get the exe2 info then we can get using:
string path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase

Note: This way will get even the exe1 path when used in exe1 also.
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Split in Javascript 5 31
Variable Event ? 3 23
Not seen Link button 5 19
C# Comparing String Arrays. 5 28
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
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…

867 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

19 Experts available now in Live!

Get 1:1 Help Now