Freigeben über


Control.MapPathSecure-Methode

Ruft den physikalischen Pfad ab, auf den ein absoluter bzw. relativer virtueller Pfad verweist.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Protected Friend Function MapPathSecure ( _
    virtualPath As String _
) As String
'Usage
Dim virtualPath As String
Dim returnValue As String

returnValue = Me.MapPathSecure(virtualPath)
protected internal string MapPathSecure (
    string virtualPath
)
protected public:
String^ MapPathSecure (
    String^ virtualPath
)
protected String MapPathSecure (
    String virtualPath
)
protected internal function MapPathSecure (
    virtualPath : String
) : String

Parameter

  • virtualPath
    Ein relativer URL oder ein zum Stamm relativer URL.

Rückgabewert

Der physikalische Pfad zu der angeforderten Datei.

Ausnahmen

Ausnahmetyp Bedingung

HttpException

Tritt ein, wenn das Serversteuerelement über keine Berechtigungen zum Lesen der resultierenden zugeordneten Datei verfügt.

Hinweise

Diese Methode kann nur von Serversteuerelementen mit Berechtigungen zum Lesen von Dateien verwendet werden, die Teil vollständig vertrauenswürdiger DLL-Dateien sind (z. B. System.Web.dll). Dies kann vor Sicherheitsverletzungen schützen.

Beispiel

Im folgenden Beispiel wird mithilfe der MapPathSecure-Methode der physikalische Pfad eines virtuellen Verzeichnisses des enthaltenden Page-Objekts oder UserControl-Objekts abgerufen.

' 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
// 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(get_TemplateSourceDirectory()) + "<br>");

// Get all the files from the absolute path of 'MyControl';
// using TemplateSourceDirectory which gives the virtual Directory.
String myFiles[] = Directory.GetFiles(MapPathSecure(
    get_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.get_Item(i) + "<br>");
}  

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Web.UI-Namespace