獲取站點根目錄:
Server.MapPath(Request.ServerVariables["PATH_INFO"]) Server.MapPath("/") Server.MapPath("")//當前代碼文件所在的目錄路徑 Server.MapPath(".") Server.MapPath("../") Server.MapPath("..")
獲取應用程序根目錄:
// 獲取程序的基目錄。 System.AppDomain.CurrentDomain.BaseDirectory // 獲取和設置包括該應用程序的目錄的名稱。 System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase