Server.MapPath()获取绝对路径
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()获取绝对路径的更多相关文章
- Server.MapPath()获取本机绝对路径
1. Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath("./&qu ...
- 【转载】ASP.NET中Server.MapPath方法获取网站根目录总结
在ASP.NET网站应用程序中,可以通过Server.MapPath方法来获取跟服务器有关的目录信息,如获取网站的根目录.获取当前代码文件所在的目录路径.获取当前代码所在路径的上级路径等.Server ...
- Server.MapPath()目录详解
最近在做相关的开发,碰到了Server.MapPath(),顺便来温习一下 Server.MapPath()获取网站的目录详解 ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 如果当前 ...
- 转:Server.MapPath相关
如果你从Page类继承的类中执行这条语句,才可以简单地使用 DataBase = Server.MapPath("data.mdb");否则写全命名空间:System.Web.Ht ...
- string s = HttpContext.Current.Server.MapPath("");
string s = HttpContext.Current.Server.MapPath(""); 获取当前文件夹路径 而后用相对路径读取图片
- ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath、Server.MapPath(转载)
1.Request.ApplicationPath->当前应用的目录 Jsp中, ApplicationPath指的是当前的application(应用程序)的目录,ASP.NET中也是这个 ...
- Server.MapPath() 解析
Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 ./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 1.Server.MapPath("/&qu ...
- asp于Server.MapPath用法
总是忘记Server.MapPath的用法,以下记录了,以后使用: 总注:Server.MapPath获得的路径都是server上的物理路径,也就是常说的绝对路径 1.Server.MapPath(& ...
- Server.MapPath方法的应用方法
老是忘记Server.MapPath的使用方法了,下面记录一下,以备后用:总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径1.Server.MapPath(&q ...
随机推荐
- 如何查询redhat的版本信息
cat /etc/redhat-release lsb_release -a
- Android常见工具类封装
MD5加密 import android.annotation.SuppressLint; import java.security.MessageDigest; public class MD5 { ...
- map的实现
1.map的实现是使用平衡树,AVL树或者红黑树. 2.在无序的情况下,查找为常数时间.有序的时候,查找为对数时间.二叉排序树(BST)就是为了解决这个问题. 3.但是,极端情况下,BST的查找效率退 ...
- jquery Mobile点击显示加载等待效果
点击某个按钮或链接时,触发等待加载效果: <script> <!-- $(document).bind("mobileinit", function(){ }); ...
- [Jobdu] 题目1497:面积最大的全1子矩阵
题目描述: 在一个M * N的矩阵中,所有的元素只有0和1,从这个矩阵中找出一个面积最大的全1子矩阵,所谓最大是指元素1的个数最多. 输入: 输入可能包含多个测试样例.对于每个测试案例,输入的第一行是 ...
- [Angular2 Router] Optional Route Query Parameters - The queryParams Directive and the Query Parameters Observable
In this tutorial we are going to learn how to use the Angular 2 router to pass optional query parame ...
- careercup-高等难度 18.5
18.5 有个内含单词的超大文本文件,给定任意两个单词,找出在这个文件中这两个单词的最短距离(也即相隔几个单词).有办法在O(1)时间里完成搜索操作吗?解法的空间复杂度如何? 解法1:我们假设单词wo ...
- 基于Bootstrap的jQuery开关按钮组合
Bootstrap是一款由Twitter推出的开源前端开发包,功能非常强大.今天我们要分享的这款jQuery开关按钮组合就是基于Bootstrap框架的,看了按钮的主题样式,也都是Bootstrap的 ...
- python代码查询港澳通行证办理进度
查询港澳通行证办理进度查询的python 3.3代码.利用socket请求相关网站,获得结果后利用正则找出办理进度.其实用urllib代码会更简洁,不过当时在下还不熟悉urllib~ 直接上代码: i ...
- python3.x爬取美团信息
在之前的文章中,笔者有提到,我们要在实践中去学习python,笔者有天就想着要不要爬点东西呢,跃跃欲试的节奏啊,想来想去,想到美团了,那么首先笔 者想给自己确定一个目标,就是我要爬什么样的数据,我要爬 ...