MapPath返回与 Web 服务器上的指定虚拟路径相对应的物理文件路径的一种方法。

简介:

    1.Server.MapPath 所获得的路径都是服务器上的物理路径,也就是常说的绝对路径。

    2.全名: System.Web.HttpContext.Current.Server.MapPath

注意点:

    1、Server.MapPath("/") :获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\。
    2、Server.MapPath("./") : 获得所在页面的当前目录,等价于 Server.MapPath("")。
    3、Server.MapPath("../") : 获得所在页面的上级目录
    4、 Server.MapPath("~/") : 获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。

posted on 2013-03-08 17:10  Giser-阿飞  阅读(1070)  评论(0编辑  收藏  举报