2012年4月11日 星期三

[.Net] To Get Server Path


Server.MapPath is a static method which could get physical path from web server.
It is defined at namespace System.Web.HttpContext.Current.Server.MapPath
Example usages below:
1、Server.MapPath("/") : to get root path of web site.
       such as C:\Inetpub\wwwroot\
2、Server.MapPath("./") : to get path of the page, equal to Server.MapPath("")。
3、Server.MapPath("../") : to get parent path of the page.
4、 Server.MapPath("~/") : to get physical path of the application
       such as C:\Inetpub\wwwroot\ExampleSite\


Reference:

沒有留言:

張貼留言