I want to get the folder in which my current project is located.
The only way I know to access something in my current folder is this:
System.Reflection.Assembly.GetExecutingAssembly().Location
However, that takes me to an address of the form:
Z:\path\to\my\things\MyProject\bin\x86\Debug\MyProject.dll
Instead of getting to this address, I would just want to get to:
Z:\path\to\my\things\MyProject
I realised that I can achieve that by doing this:
Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "../../..")
However, I don't like that I have to hardcode "../../.."
.
Is there a way of achieving the same thing without the hardcoding?
EDIT
If I try Environment.CurrentDirectory
or System.IO.Directory.GetCurrentDirectory();
, as suggested in this question, I get to C:\Windows\System32
, so that's not helpful at all.