Page.MapPath(String) Page.MapPath(String) Page.MapPath(String) Page.MapPath(String) Method

定義

擷取虛擬路徑 (絕對或相對) 或應用程式相對路徑所對應至的實體路徑。Retrieves the physical path that a virtual path, either absolute or relative, or an application-relative path maps to.

public:
 System::String ^ MapPath(System::String ^ virtualPath);
public string MapPath (string virtualPath);
member this.MapPath : string -> string
Public Function MapPath (virtualPath As String) As String

參數

virtualPath
String String String String

表示虛擬路徑的 StringA String that represents the virtual path.

傳回

與虛擬路徑或應用程式相對路徑關聯的實體路徑。The physical path associated with the virtual path or application-relative path.

範例

下列範例會使用MapPath方法,以取得子資料夾的實體路徑。The following example uses the MapPath method to obtain the physical path of a subfolder. 然後將附加的檔案名稱,會從讀取Text屬性TextBox控制項。It then appends the file name that is read from the Text property of a TextBox control. 結果會是該檔案的絕對實體路徑。The result is the absolute physical path to that file.

String fileNameString = this.MapPath(subFolder.Text);
fileNameString += "\\" + fileNameTextBox.Text;
Dim fileNameString As String  = Me.MapPath(subFolder.Text)
fileNameString += "\\" + fileNameTextBox.Text

備註

警告

MapPath屬性可能包含裝載環境的機密資訊。The MapPath property can potentially contain sensitive information about the hosting environment. 傳回的值不應該向使用者顯示。The return value should not be displayed to users.

適用於

另請參閱