• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 642
  • Last Modified:

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

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
Parth48
Asked:
Parth48
1 Solution
 
Deepu AbrahamR & D Engineering ManagerCommented:
Try this:

String name = System.Windows.Forms.Application.ExecutablePath;
0
 
Carl TawnSystems and Integration DeveloperCommented:
Application.StartupPath is the path your exe is running from.
0
 
Sudhakar PulivarthiCommented:
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
 
Sudhakar PulivarthiCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now