asp.net获取网站目录物理路径示例
来源: 互联网 发布时间:2014-08-25
本文导语: 页面后台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....
页面后台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 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 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 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";
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。