Control.MapPathSecure(String) Control.MapPathSecure(String) Control.MapPathSecure(String) Control.MapPathSecure(String) Method

定義

仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

protected public:
 System::String ^ MapPathSecure(System::String ^ virtualPath);
protected internal string MapPathSecure (string virtualPath);
member this.MapPathSecure : string -> string
Protected Friend Function MapPathSecure (virtualPath As String) As String

パラメーター

virtualPath
String String String String

相対 URL、またはルートに対して相対的な URL。A relative or root relative URL.

戻り値

要求されたファイルへの物理パス。The physical path to the requested file.

例外

virtualPathnull または空の文字列 ("") です。virtualPath is null or an empty string ("").

次の例ではMapPathSecure 、メソッドを使用してPage 、オブジェクトまたはUserControlオブジェクトの仮想ディレクトリの物理パスを取得します。The following example uses the MapPathSecure method to obtain the physical path of a virtual directory of the containing Page or UserControl object.

// An HttpException occurs if the server control does not,;
// have permissions to read the resulting mapped file. 
     output.Write("The Actual Path of the virtual directory : "+
     MapPathSecure(TemplateSourceDirectory)+"<br>");

    // Get all the files from the absolute path of 'MyControl';
    // using TemplateSourceDirectory which gives the virtual Directory.
        string [] myFiles=
        Directory.GetFiles(MapPathSecure(TemplateSourceDirectory));
        output.Write("The files in this Directory are <br>");

         // List all the files.
         for (int i=0;i<myFiles.Length;i++)
            output.Write(myFiles[i]+"<br>");
' An HttpException occurs if the server control does not,;
' have permissions to read the resulting mapped file.
output.Write("The Actual Path of the virtual directory : " & _
            MapPathSecure(TemplateSourceDirectory) & "<br>")

' Get all the files from the absolute path of 'MyControl';
' using TemplateSourceDirectory which gives the virtual Directory.
Dim myFiles As String() = Directory.GetFiles(MapPathSecure(TemplateSourceDirectory))
output.Write("The files in this Directory are <br>")

' List all the files.
Dim i As Integer
For i = 0 To myFiles.Length - 1
   output.Write(myFiles(i) & "<br>")
Next i

注釈

このメソッドは、ファイルを読み取るアクセス許可を持ち、完全に信頼された .dll ファイル (system.servicemodel など) の一部であるサーバーコントロールでのみ使用できます。This method can only be used by server controls that have permissions to read files and which are part of fully trusted .dll files, such as System.Web.dll. これにより、セキュリティ侵害を防ぐことができます。This helps prevent security breaches.

適用対象