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 ...
随机推荐
- Codeforces Round #311 (Div. 2) D. Vitaly and Cycle 图论
D. Vitaly and Cycle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/p ...
- poj - 2774 - Long Long Message
题意:输入2个长度不超过100000的字符串,问它们最长公共子串的长度. 题目链接:http://poj.org/problem?id=2774 ——>>后缀数组!后缀数组!-从LJ的&l ...
- qt creator中使用qwt插件
前提:我用mingw编译的qwt. 将qwt插件集成到qt designer非常easy.仅仅要把qwt编译的qwt_designer_plugin.dll复制到C:\Qt\Qt5.3.1\5.3\m ...
- ORCLE INNODB 博客与 innodb_lru_scan_depth
https://blogs.oracle.com/mysqlinnodb/ http://mysqllover.com/?p=485 •MySQL. MySQL 5.6.10 http://www.m ...
- c#使用MethodInvoker解决跨线程访问控件
功能函数测试集锦(77) C#专区(114) 版权声明:本文为博主原创文章,未经博主允许不得转载. .net 原则上禁止跨线程访问控件,因为这样可能造成错误的发生,有一种方法是禁止编译器对跨线 ...
- Google搜索技巧-从入门到精通(从此学习进步、工作顺心)
转载:http://www.blogbus.com/koudaizhi-logs/55687286.html 一 GOOGLE简介 Google (www.google.com)是一个搜寻引擎,由某 ...
- Is an MTD device a block device or a char device?
转:http://www.linux-mtd.infradead.org/faq/general.html#L_mtd_what Note, you can find Ukranian transla ...
- 关于android listview去掉分割线
1.设置android:divider="@null" 2.android:divider="#00000000" #00000000后面两个零表示透明 3.. ...
- 关于android在Service中弹出Dialog对话框
在创建好AlertDialog类型对象后,要 dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); 同时还 ...
- Code Jam 2008 APAC local onsites Problem C. Millionaire —— 概率DP
题意: 你有X元钱,进行M轮赌博游戏.每一轮可以将所持的任意一部分钱作为赌注(赌注为0元表示这一轮不押),赌注可以是小数的,不是一定要整数.每一轮 赢的概率为P,赢了赌注翻倍,输了赌注就没了.如果你最 ...