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

  • 相关阅读:
    case class inheritance
    [Akka]发送一条消息的内部流程
    Java 8 新特性
    大数据学习笔记
    磁盘结构
    AtomicReference 和 volatile 的区别
    How to support both ipv4 and ipv6 address for JAVA code.
    使用JProfiler分析定位java内存泄露memory leak
    redhat mount iso as one yum repository
    Linux Shell常用技巧
  • 原文地址:https://www.cnblogs.com/donchen/p/3944728.html
Copyright © 2011-2022 走看看