Nyelv

Control.MapPathSecure(String) Metódus

Definíció

Lekéri azt a fizikai útvonalat, amelybe egy virtuális elérési út abszolút vagy relatív értékként van leképezve.

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

Paraméterek

virtualPath
String

Relatív vagy gyökér relatív URL-cím.

Válaszok

A kért fájl fizikai elérési útja.

Kivételek

virtualPath üres null sztring ("").

Példák

Az alábbi példa a MapPathSecure metódus használatával szerzi be a tároló Page vagy UserControl objektum virtuális könyvtárának fizikai elérési útját.

// 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

Megjegyzések

Ezt a módszert csak olyan kiszolgálóvezérlők használhatják, amelyek olvasási engedéllyel rendelkeznek, és amelyek teljes mértékben megbízható .dll fájlok részei, például System.Web.dll. Ez segít megelőzni a biztonsági incidenseket.

A következőre érvényes: