Click here to Skip to main content
15,886,770 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir i would like to know how can get Current project Environment. actually i am using this below code to get but this is return D: directory. my project in E: Drive it should be return E: dreive. so plzzz help me sir.
string filename = Environment.CurrentDirectory.ToString();
Posted
Updated 21-Jul-11 1:42am
v2
Comments
Toniyo Jackson 21-Jul-11 7:45am    
What you are doing is correct. There may be some other problem.
sk saini 21-Jul-11 7:54am    
Agree with Toniyo Jackson.
anilthegreat 21-Jul-11 8:05am    
which type of other problems? actually i am saving images within project's folder....
#realJSOP 21-Jul-11 8:18am    
You shouldn't do that. You should use the user's appdata folder

To get the currently running application's folder:

C#
string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath);


To get the current working directory:

C#
string path = Environment.CurrentDirectory;


The application folder and the "working" folder are not always necessarily the same.
 
Share this answer
 
Comments
[no name] 21-Jul-11 8:14am    
Nice, my 5!
Reiss 21-Jul-11 8:52am    
take 5
first:
CurrentDirectory is a string so you can remove ToString().

further: read http://msdn.microsoft.com/en-us/library/system.environment.currentdirectory.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900