1

I try to get current directory path of my project . I tried:

  1. System.IO.Directory.GetDirectoryRoot();

  2. Environment.CurrentDirectory;

  3. System.IO.Path.GetFullPath(".\");

and in all option I get :

C:\Program Files (x86)\IIS Express\

Instead of project path .

Does anyone have a solution?

openshac
  • 4,966
  • 5
  • 46
  • 77
Shira
  • 63
  • 1
  • 9

2 Answers2

7

I found a link on the net : Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?

You should use : string path = AppDomain.CurrentDomain.BaseDirectory ;

Indeed, the others are values which can change during the program's execution.

Community
  • 1
  • 1
jd6
  • 429
  • 3
  • 9
1

You might want to try this out:

string thePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;

Not sure if it works for you, but you can always try.

Community
  • 1
  • 1
Koen
  • 634
  • 3
  • 14