Last active
June 7, 2017 02:45
-
-
Save songzheng45/f7833a510924173ce968c946eeedfec5 to your computer and use it in GitHub Desktop.
ASP.NET-MapPath-获取虚拟路径的实际磁盘路径
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ASP.NET WebForm,ASP.NET MVC | |
var sPath = Server.MapPath("/FilePath/"); | |
// ASP.NET WebAPI | |
// 当 WebAPI 寄宿在非IIS下时(如自寄宿),无法访问HttpContext类,因此要调用这个方法来获取虚拟路径的实际磁盘路径 | |
var sPath = System.Web.Hosting.HostingEnvironment.MapPath("/FilePath/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考:
How to Map the File Path in Asp.Net Web API