天天看點

Server.MapPath()目錄詳解

  1. ./目前目錄
  2. /網站主目錄
  3. ../上層目錄
  4. ~/網站虛拟目錄
  • 如果目前的網站目錄為E:\www123,應用程式虛拟目錄為E:\www123\wlj ,浏覽的頁面路徑為E:\www123\wlj\haha\heihei.asp。
  • 例子:在heihei.asp頁面中的具體使用如下
  • Server.MapPath("./")   傳回路徑為:E:\www123\wlj\haha
  • Server.MapPath("/")    傳回路徑為:E:\www123
  • Server.MapPath("../")   傳回路徑為:E:\www123\wlj
  • Server.MapPath("~/")   傳回路徑為:E:\www123\wlj
  • server.MapPath(request.ServerVariables("Path_Info"))
  • Request.ServerVariables("Path_Translated")
  • 上面兩種方式傳回路徑為 D:\www123\wlj\haha\heihei.asp