arsena
arsena

Reputation: 1975

Can't get project directory path in MVC application

I'm trying to get project directory path(My Documents\Visual Studio 2013\Projects\SmartPhoneCatalog\SmartPhoneCatalog).

tried Directory.GetCurrentDirectory and Enviroment.CurrentDirectory but both return IIS Express folder path. (C:\Program Files (x86)\IIS Express\)

Any suggestions which method to use?

Upvotes: 3

Views: 5890

Answers (3)

ApiFox
ApiFox

Reputation: 123

You could do:

 HttpContext.Current.Request.PhysicalApplicationPath

Upvotes: 0

codebased
codebased

Reputation: 7073

try with HostingEnvironment.ApplicationPhysicalPath

Upvotes: 10

danludwig
danludwig

Reputation: 47375

Try AppDomain.CurrentDomain.BaseDirectory.

If memory serves, this will get you to My Documents\Visual Studio 2013\Projects\SmartPhoneCatalog\SmartPhoneCatalog\bin, so you may have to go up one directory from here.

Upvotes: 6

Related Questions