当前位置: 编程技术>.net/c#/asp.net
asp.net获取网站目录物理路径
来源: 互联网 发布时间:2014-08-30
本文导语: 1,页面后台cs文件的相对网站根目录的路径/view/Atlas 代码示例: string rootPath1= Server.MapPath("~"); string rootPath2 = Request.ApplicationPath; string path1 = Server.MapPath("upload"); string path2 = Server.MapPath(""); string path3 = Server.MapPath("."); strin...
1,页面后台cs文件的相对网站根目录的路径/view/Atlas
代码示例:
string rootPath1= Server.MapPath("~");
string rootPath2 = Request.ApplicationPath;
string path1 = Server.MapPath("upload");
string path2 = Server.MapPath("");
string path3 = Server.MapPath(".");
string path4 = Server.MapPath("..");
string path5 = Server.MapPath(Request.ServerVariables["PATH_INFO"]);
string rootPath2 = Request.ApplicationPath;
string path1 = Server.MapPath("upload");
string path2 = Server.MapPath("");
string path3 = Server.MapPath(".");
string path4 = Server.MapPath("..");
string path5 = Server.MapPath(Request.ServerVariables["PATH_INFO"]);
输出结果:
代码示例:
string rootpath1= "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\cfzs\Web";
string rootpath2= "/Web";
string path1 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\upload\cfzs\Web\view\Atlas\upload";
string path2 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\cfzs\Web\view\Atlas";
string path3 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\cfzs\Web\view\Atlas";
string path4 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\cfzs\Web\view";
string path5 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\Add.aspx\cfzs\Web\view\Atlas\Add.aspx";
string rootpath2= "/Web";
string path1 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\upload\cfzs\Web\view\Atlas\upload";
string path2 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\cfzs\Web\view\Atlas";
string path3 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\cfzs\Web\view\Atlas";
string path4 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\cfzs\Web\view";
string path5 = "F:\ASP.NET_Projects\超凡装饰\cfzs\Web\view\Atlas\Add.aspx\cfzs\Web\view\Atlas\Add.aspx";