Recupera il percorso fisico al quale è associato un percorso virtuale, assoluto o relativo.
Assembly: System.Web (in System.Web.dll)
Protected Friend Function MapPathSecure ( _ virtualPath As String _ ) As String
protected internal string MapPathSecure( string virtualPath )
protected public: String^ MapPathSecure( String^ virtualPath )
member MapPathSecure : virtualPath:string -> string
Parametri
- virtualPath
- Tipo: System.String
URL relativo o relativo alla directory radice.
| Eccezione | Condizione |
|---|---|
| ArgumentNullException |
Il valore di virtualPath è null oppure una stringa vuota (""). |
Il metodo può essere utilizzato solo dai controlli server che dispongono delle autorizzazioni per la lettura di file e che sono parte di file DLL completamente attendibili, come System.Web.dll. Contribuisce a impedire violazioni della sicurezza.
Nell'esempio che segue viene utilizzato il metodo MapPathSecure per ottenere il percorso fisico di una directory virtuale dell'oggetto contenitore Page oppure UserControl.
' 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>");
.NET Framework
Supportato in: 4, 3.5, 3.0, 2.0, 1.1, 1.0Windows 7, Windows Vista SP1 o versione successiva, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (componenti di base del server non supportati), Windows Server 2008 R2 (componenti di base del server supportati con SP1 o versione successiva), Windows Server 2003 SP2
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.