?
Solved

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

Posted on 2011-02-23
5
Medium Priority
?
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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