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

C:\Inetpub\wwwroot\

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

C:\Inetpub\wwwroot\Example\
     注:等效于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:\Inetpub\wwwroot\EnglishClub\manage\WebForm1.aspx

C:\Inetpub\wwwroot\
C:\Inetpub\wwwroot\EnglishClub\manage
C:\Inetpub\wwwroot\EnglishClub\manage

C:\Inetpub\wwwroot\EnglishClub\
C:\Inetpub\wwwroot\EnglishClub

Server.MapPath()获取绝对路径的更多相关文章

  1. Server.MapPath()获取本机绝对路径

    1.    Server.MapPath("/")  应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath("./&qu ...

  2. 【转载】ASP.NET中Server.MapPath方法获取网站根目录总结

    在ASP.NET网站应用程序中,可以通过Server.MapPath方法来获取跟服务器有关的目录信息,如获取网站的根目录.获取当前代码文件所在的目录路径.获取当前代码所在路径的上级路径等.Server ...

  3. Server.MapPath()目录详解

    最近在做相关的开发,碰到了Server.MapPath(),顺便来温习一下 Server.MapPath()获取网站的目录详解  ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 如果当前 ...

  4. 转:Server.MapPath相关

    如果你从Page类继承的类中执行这条语句,才可以简单地使用 DataBase = Server.MapPath("data.mdb");否则写全命名空间:System.Web.Ht ...

  5. string s = HttpContext.Current.Server.MapPath("");

    string s = HttpContext.Current.Server.MapPath(""); 获取当前文件夹路径 而后用相对路径读取图片

  6. ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、Server.MapPath(转载)

    1.Request.ApplicationPath->当前应用的目录   Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这个 ...

  7. Server.MapPath() 解析

    Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 1.Server.MapPath("/&qu ...

  8. asp于Server.MapPath用法

    总是忘记Server.MapPath的用法,以下记录了,以后使用: 总注:Server.MapPath获得的路径都是server上的物理路径,也就是常说的绝对路径 1.Server.MapPath(& ...

  9. Server.MapPath方法的应用方法

    老是忘记Server.MapPath的使用方法了,下面记录一下,以备后用:总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径1.Server.MapPath(&q ...

随机推荐

  1. Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) B. Guess the Permutation 水题

    B. Guess the Permutation 题目连接: http://www.codeforces.com/contest/618/problem/B Description Bob has a ...

  2. HDU 5573 Binary Tree 构造

    Binary Tree 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5573 Description The Old Frog King lives ...

  3. ntoskrnl.exe损坏或丢失的解决方式

    同事的电脑启动时出现下面提示:"因下面文件损坏或丢失Windows无法启动 %systemroot%\system32\ntoskrnl.exe,请又一次安装以上文件的拷贝"(Wi ...

  4. JSP中Session的使用

    JSP session使用方法 <%@page contentType="text/html;charset=GB2312"%><html>  <he ...

  5. 目标检測的图像特征提取之(一)HOG特征

    1.HOG特征: 方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视觉和图像处理中用来进行物体检測的特征描写叙述子.它通过计算和统计图像局部区 ...

  6. jquery.validate+jquery.form提交的三种方式

    原文:http://www.cnblogs.com/datoubaba/archive/2012/06/06/2538873.html jquery.validate+jquery.form提交的三种 ...

  7. 【ZZ】快速學會開發Android App

    http://www.cc.ntu.edu.tw/chinese/epaper/0022/20120920_2209.html 作者:吳玉舒 / 臺灣大學計算機及資訊網路中心程式設計組幹事 智慧型手機 ...

  8. java中的包有那些 ???

    java.util工具包java.sql数据库包java.io输入输出流包java.net网络包java.lang基础包这些是基本的包,还有一些其他的例如集合,反射等的工具包,你可以去查一下java ...

  9. LeetCode26 Remove Duplicates from Sorted Array

    题目: Given a sorted array, remove the duplicates in place such that each element appear only once and ...

  10. LeetCode25 Reverse Nodes in k-Group

    题意: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list ...