MapPath方法,返回与 Web 服务器上的指定虚拟路径相对应的物理文件路径。 请问最终将输出什么?
先看一张图:
说明:
站点voteengine的主目录为F:worksP080430_01_VoteEngineV4DEVELOPSOURCEweb
public为虚拟目录,指向E:CaptureImages
public下的note为虚拟目录,指向F:bin
upload目录不存在
看看下面的代码:string[] s = new string[] { "", "", "","" };
s[0] = Server.MapPath("~/upload/");
s[1] = Server.MapPath("~/public/");
s[2] = Server.MapPath("~/public/note");
s[3] = Server.MapPath("~/public/")+"note";
foreach (string item in s)
{
Response.Write("<br />" + item);
}
3 Comments
Leave a Reply
Using Gravatars in the comments - get your own and be recognized!
XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>
F:\works\P080430_01_VoteEngineV4\DEVELOP\SOURCE\web
E:\CaptureImages
F:\bin
E:\CaptureImages\note
不知道对不, 没开 VS , 全靠猜的…
BTW: 终于能发评论了, 之前在 Linux 下还以为是浏览器兼容问题
F:\works\P080430_01_VoteEngineV4\DEVELOP\SOURCE\web\upload\
E:\CaptureImages\
F:\bin
E:\CaptureImages\note
原来如此,受教了
我以为不存在的话, .NET 会自动找到存在的父级目录呢