1、string str1 = Request.ApplicationPath.ToString(); 返回路径为:\HolterClientWeb
2、HttpServerUtility.MapPath 方法 解释:返回对应于 Web 服务器上指定的虚拟路径的物理文件路径。
string path=Server.MapPath(Request.ApplicationPath + "/UpLoad/ReportFile");
调试后:
string str3= Server.MapPath("./");
C:\\Users\\Administrator\\Desktop\\HolterClientWeb\\FileHandle\\
string str4= Server.MapPath("../");
C:\\Users\\Administrator\\Desktop\\HolterClientWeb\\
string str5 = Server.MapPath("~/");
C:\\Users\\Administrator\\Desktop\\HolterClientWeb\\
附加:
./当前目录
/网站主目录
../上层目录
~/网站虚拟目录
3、 string exe = HttpContext.Current.Server.MapPath("pdf2swf.exe");
调试后:
4、string str6 = Server.MapPath(Request.ServerVariables["Path_Info"]);
5、string str7 = Request.ServerVariables["Path_Translated"];
其它参考地址:http://blog.csdn.net/ecdyf1989/article/details/5877648
http://www.cnblogs.com/leixiaoling/archive/2012/03/30/2425466.html
原文:http://www.cnblogs.com/vakeynb/p/3751399.html