Server.MapPath()的功能: 返回與 Web 服務(wù)器上的指定虛擬路徑相對應(yīng)的物理文件路徑。 命名空間: System.Web 程序集: System.Web(在 System.Web.dll 中) public string MapPath( string path ) 其中參數(shù)path 類型:System.String Web 服務(wù)器的虛擬路徑。 返回值 類型:System.String 與 path 相對應(yīng)的物理文件路徑。 如果 path 為 null,MapPath 方法將返回包含當(dāng)前應(yīng)用程序的目錄的完整物理路徑。 安全說明 MapPath 方法很可能包含有關(guān)承載環(huán)境的敏感信息。 不應(yīng)向用戶顯示返回值。 .NET Framework 受以下版本支持:4.5、4、3.5、3.0、2.0、1.1、1.0 例子: Server.MapPath("")返回當(dāng)前頁面所在的文件夾的路徑,如D:\wwwroot\KeleyiWeb\Test Server.MapPath("/")返回站點的根目錄D:\wwwroot\KeleyiWeb Server.MapPath("./") :返回當(dāng)前頁面所在的物理文件路徑:D:\wwwroot\KeleyiWeb\Test Server.MapPath("../"):返回當(dāng)前頁面所在的上一級的物理文件夾路徑:D:\wwwroot\KeleyiWeb Server.MapPath("~/"):返回應(yīng)用程序的虛擬目錄(路徑):D:\wwwroot\KeleyiWebServer.MapPath("~"):返回應(yīng)用程序的虛擬目錄(路徑):D:\wwwroot\KeleyiWeb |
|