天天看點

虛拟目錄

<a target="_blank" href="http://www.cnblogs.com/yangfan/archive/2008/05/23/1205976.html">Server.MapPath()</a>

./目前目錄

/網站主目錄

../上層目錄

~/網站虛拟目錄

如果目前的網站目錄為E:\wwwroot   應用程式虛拟目錄為E:\wwwroot\company 浏覽的頁面路徑為E:\wwwroot\company\news\show.asp

在show.asp頁面中使用

Server.MapPath("./")   傳回路徑為:E:\wwwroot\company\news

Server.MapPath("/")    傳回路徑為:E:\wwwroot

Server.MapPath("../")   傳回路徑為:E:\wwwroot\company

Server.MapPath("~/")   傳回路徑為:E:\wwwroot\company

server.MapPath(request.ServerVariables("Path_Info"))

Request.ServerVariables("Path_Translated") 

上面兩種方式傳回路徑為 D:\wwwroot\company\news\show.asp

繼續閱讀