简体   繁体   中英

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?

尝试使用HostingEnvironment.ApplicationPhysicalPath

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.

你可以这样做:

 HttpContext.Current.Request.PhysicalApplicationPath

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM