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\。

相关文章:

  • 2021-06-05
  • 2021-10-13
  • 2021-06-22
  • 2021-09-27
  • 2021-09-15
猜你喜欢
  • 2022-01-19
  • 2022-12-23
  • 2021-12-14
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案