Server.MapPath方法的应用方法

总是忘记Server.MapPath的使用方法了,下面记录一下,以备后用:
全命名空间: System.Web.HttpContext.Current.Server.MapPath();
总注:Server.MapPath得到的路径都是服务器上的物理路径,也就是常说的绝对路径 一、Server.MapPath("/") 注:得到应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\。 二、Server.MapPath("./") 注:得到所在页面的当前目录,等价于Server.MapPath("")。 三、Server.MapPath("../") 注:得到所在页面的上级目录。 四、Server.MapPath("~/") 注:得到当前应用级程序的目录,若是是根目录,就是根目录,若是是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。
相关文章
相关标签/搜索