I need to file something in my ASP.NET MVC project. I have two folders in my single project, Main and context is called.
From my head, I'm calling a class from my reference .csproj file. From there, I should go to my TargetFile, which also resides in the reference folder. I C: \ project \ Main when I use AppDomain.CurrentDomain.BaseDirectory , when I C: \ project \ Reference should be .
So I thought I could use the Environment.CurrentDirectory , which is expected to point me to the reference folder instead of the main, but unfortunately it is C: \ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE . I have tried the directory. GetCurrentDirectory () , but I get the same result.
I have to for the environment. Current directory to give me c: \ project \ context . I think I should give the reference folder instead of the main folder because it is being called from context, but it's not going to my project folder right now.
Is there any way I can do without defining my directory elsewhere? I really want to put my file path in my project for no hardcoding.
The usual way to find files that are part of an asp.net application (or for that matter ASP.NET MVC) is to use Server.MapPath ("~ / folder / somefile.txt") , which will be automatically converted to a full path where ~ The root of the web site is no matter what you are inserting into the ASP.NET application or from where they all will end in the bin folder. E
Comments
Post a Comment