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

  • 相关阅读:
    VMware虚拟机下如何安装一个64位的win7系统
    无人驾驶刚刚开始的未来
    Ruby on Rails开发Web应用的基本概念
    Hibernate学习(1)简单介绍
    Linux pipe 源代码分析
    【知识梳理1】Android触摸事件机制
    【CODEFORCES】 C. Dreamoon and Strings
    LightOJ
    [leetcode]Maximum Subarray
    25个增强iOS应用程序性能的提示和技巧 — 中级篇
  • 原文地址:https://www.cnblogs.com/donchen/p/3944728.html
Copyright © 2011-2022 走看看