zoukankan      html  css  js  c++  java
  • Server.MapPath()获取绝对路径

    1.    Server.MapPath("/")  应用程序根目录所在的位置 如

    C:Inetpubwwwroot

    2.Server.MapPath("./")  表示所在页面的当前目录 
          注:等价于Server.MapPath("")  返回 Server.MapPath("")所在页面的物理文件路径
          3.Server.MapPath("../")表示上一级目录 
          4.Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置如:   

    C:InetpubwwwrootExample
         注:等效于Server.MapPath("~"),即相对路径

    Java代码 :
    string filename=Server.MapPath("./") + @"Web.config";   
    string filename=Server.MapPath("./") + "/Web.config";   
    string filename=Server.MapPath("") + @"Web.config"  

    string filename=Server.MapPath("./") + @"Web.config";

    string filename=Server.MapPath("./") + "/Web.config";

    string filename=Server.MapPath("") + @"Web.config"

    string Server.MapPath(string path)
    ��返回与Web服务器上的指定虚拟路径相对应的物理文件路径。�

    Html代码 
    <%=Server.MapPath(Request.ServerVariables["PATH_INFO"])%>  
      
    �<%= Server.MapPath("/")%>  
    ��<%= Server.MapPath("")%>  
    ��<%=Server.MapPath(".")%>  
      
    ��<%= Server.MapPath("../")%>  
    ��<%= Server.MapPath("..")%>��  

    <%=Server.MapPath(Request.ServerVariables["PATH_INFO"])%> 

    ��<%= Server.MapPath("/")%>

    ��<%= Server.MapPath("")%>

    ��<%=Server.MapPath(".")%> 

    ��<%= Server.MapPath("../")%>

    ��<%= Server.MapPath("..")%>�� 
    �以上的代码在http://localhost/EnglishClub/manage/WebForm1.aspx页面
    ��运行结果:
    ��C:InetpubwwwrootEnglishClubmanageWebForm1.aspx
    ��
    ��C:Inetpubwwwroot
    ��C:InetpubwwwrootEnglishClubmanage
    ��C:InetpubwwwrootEnglishClubmanage
    ��
    ��C:InetpubwwwrootEnglishClub
    ��C:InetpubwwwrootEnglishClub

  • 相关阅读:
    php操作redis cluster集群成功实例
    js算法-快速排序(Quicksort)
    如何编写自己的虚拟DOM
    一文带你看透kubernetes 容器编排系统
    SpringBoot AOP控制Redis自动缓存和更新
    机器学习中的numpy库
    时间戳转自定义日期格式和刚刚、十分钟前等友好日期格式
    Python数据处理实例
    Spark1.x和2.x如何读取和写入csv文件
    掌握这个Python小技巧,轻松构建cytoscape导入文件
  • 原文地址:https://www.cnblogs.com/donchen/p/3944728.html
Copyright © 2011-2022 走看看