1.符号“/”指程序运行所在根目录,即IIs所在目录。
如果iis所在目录为:d:/programs
解决方案为d:/programs/d
网站路径为:d:/programs/d/web/
符号“/”代表的是:d:/programs,不管你的网站前面有多少级,都应该作为一个整体。
2.符号“~/”,则是指网站所在根目录。即d:/programs/d/web。
测试代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Server.MapPath("/"));
Response.Write("<br/>");
Response.Write(Server.MapPath("~/"));
}
输出结果:
C:/inetpub/wwwroot/
D:/Programs2008/WebSite2/