欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp.net获取网站目录物理路径示例

程序员文章站 2024-02-27 14:41:39
页面后台cs文件的相对网站根目录的路径/view/atlas 复制代码 代码如下: string rootpath1= server.mappath("~"); strin...
页面后台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";