I need to get to a certain file in my ASP.NET MVC project. Have two folders in my same Project, let's call them Main and Reference.
From my Main, I am calling a class from my Reference.csproj file. From there, I need to get to my TargetFile, which also lives in the Reference folder.
When I use AppDomain.CurrentDomain.BaseDirectory
i get C:\Project\Main
, when I want C:\Project\Reference
.
So I thought I could use Environment.CurrentDirectory
, which would hopefully point me to the Reference folder instead of the Main, but unfortunately it outputs C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
. I have also tried Directory.GetCurrentDirectory()
, but I get the same result.
What I need is for Environment.CurrentDirectory
to give me C:\Project\Reference
. I think it should give me the Reference folder instead of the Main folder because it is being called from inside Reference, but right now it's not even going near my Project folder.
Is there a way I can do that without defining my directory elsewhere? I really want to do this without hardcoding my file path into my project.