-
asp.net獲得路徑的方法
HttpContext.Current.Request.PhysicalPath; // 獲得當前頁面的完整物理路徑.比如 F:\XFU.NSQS\project\website\Default.aspx HttpContext.Current.Request.PhysicalApplicationPath; // 獲得當前程序運行的物理路徑比 如F:\XFU.NSQS\project\website\ HttpContext.Current.Server.MapPath(@”\”); 這個就是在頁面中的MapPath了.壹樣用法 HttpRuntime.AppDomainAppPath //這個是新發現的,很好用. 還有壹個是用來處理在asp.net中調用dll文件,而DLL文件如果想知道當前的web站點的工作目錄可以用 System.AppDomain.CurrentDomain.BaseDirectory 網站在服務器磁盤上的物理路徑: HttpRuntime.AppDomainAppPath 虛擬程序路徑: HttpRuntime.AppDomainAppVirtualPath HttpContext.Current.Request.ApplicationPath虛擬應用程序根路徑 HttpContext.Current.Server.MapPath(“.”)當前的絕對路徑 HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath)系統的根目錄 sb.Append(string.Format(“當前請求的虛擬路徑: {0}”,Server.HtmlEncode (Request.CurrentExecutionFilePath))); sb.Append(string.Format(“獲取當前應用程序的根目錄路徑: {0}”, Server.HtmlEncode(Request.ApplicationPath))); sb.Append(string.Format(“當前請求的虛擬路徑: {0}”,Server.HtmlEncode (Request.FilePath))); sb.Append(string.Format(“當前請求的虛擬路徑: {0}”,Server.HtmlEncode (Request.Path))); sb.Append(string.Format(“獲取當前正在執行的應用程序的根目錄的物理文件系統路徑: {0}”, Server.HtmlEncode(Request.PhysicalApplicationPath))); sb.Append(string.Format(“獲取與請求的 URL 相對應的物理文件系統路徑: {0}”, Server.HtmlEncode(Request.PhysicalApplicationPath))); 當前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx 獲取當前應用程序的根目錄路徑: /aDirectory 當前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx 當前請求的虛擬路徑: /aDirectory/Sample/responseHtml.aspx 獲取當前正在執行的應用程序的根目錄的物理文件系統路徑: E:\Visual Studio 2005\ 獲取與請求的 URL…