Click here to Skip to main content
15,883,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I find the root directory of my c# console application?

I've tried a few suggestions so far but all return the location of my executable like the following:
"C:\AppName\Source\Client.AppName\bin\Release"

However I want to return the following:
"C:\AppName\Source\Client.AppName"

Any idea how I can get this?

Thanks.
Posted

C:\AppName\Source\Client.AppName\bin\Release

that is the root directory. the root being where your application runs from. Why do you need to get up to where the project is from within your application?

If it's for resources etc. In VS, select them, look at the properties and set the Build Action to Content and Copy If Newer as the "Copy To Output Directory" option.
 
Share this answer
 
Comments
Kunal Chowdhury «IN» 22-Jul-10 14:19pm    
Reason for my vote of 5
This has more clear answer.
I think you will have to remove the "\bin\Release" substring yourself as the system cannot make that determination for you. For example if you move your executable to "C:\Program Files\yourname\test" there is no link between the exe and the source code.
 
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