Control.MapPathSecure メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim virtualPath As String Dim returnValue As String returnValue = Me.MapPathSecure(virtualPath)
戻り値
要求されたファイルへの物理パス。


このメソッドを使用できるのは、ファイル読み取りのアクセス許可を持ち、System.Web.dll などの完全に信頼されている .dll ファイルの一部であるサーバー コントロールだけです。この制限は、セキュリティ侵害の防止に役立ちます。

Page オブジェクトまたは UserControl オブジェクトが格納されている仮想ディレクトリの物理パスを、MapPathSecure メソッドを使用して取得する例を次に示します。
' 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>"); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Control.MapPathSecure メソッドのページへのリンク