更新:2007 年 11 月
傳回在 Web 伺服器上對應至指定虛擬路徑的實體檔案路徑。
Public Function MapPath ( _ path As String _ ) As String
Dim instance As HttpServerUtility Dim path As String Dim returnValue As String returnValue = instance.MapPath(path)
public string MapPath( string path )
public: String^ MapPath( String^ path )
public String MapPath( String path )
public function MapPath( path : String ) : String
Web 伺服器上的虛擬路徑。
對應至 path 的實體檔案路徑。
目前的 HttpContext 為 nullNothingnullptrNull 參照 (即 Visual Basic 中的 Nothing)。
如果 path 為 nullNothingnullptrNull 參照 (即 Visual Basic 中的 Nothing),則 MapPath 方法會傳回含有目前應用程式之目錄的完整實體路徑。
MapPath 方法可能會包含與裝載環境有關的敏感性資訊。傳回值不應該顯示給使用者。
下列範例會傳回含有指定網站之虛擬目錄的實體路徑。若要讀取程式碼後置模組中的 MapPath,請使用 HttpContext.Current.Server.MapPath。
Dim FilePath As String FilePath = Server.MapPath("/MyWebSite")
String FilePath; FilePath = Server.MapPath("/MyWebSite");
String filePath; filePath = get_Server().MapPath("/MyWebSite");
var filePath : String = Server.MapPath("/MyWebSite")
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98