[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-02-23
5
Medium Priority
?
633 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:Deepu Abraham
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 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