次の方法で共有


HttpServerUtility.MapPath メソッド

Web サーバーの指定した仮想パスに対応する物理ファイル パスを返します。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Function MapPath ( _
    path As String _
) As String
'使用
Dim instance As HttpServerUtility
Dim path As String
Dim returnValue As String

returnValue = instance.MapPath(path)
public string MapPath (
    string path
)
public:
String^ MapPath (
    String^ path
)
public String MapPath (
    String path
)
public function MapPath (
    path : String
) : String
適用できません。

パラメータ

  • path
    Web サーバー上の仮想パス。

戻り値

path に対応する物理ファイル パス。

例外

例外の種類 条件

HttpException

現在の HttpContext が null 参照 (Visual Basic では Nothing) です。

解説

path が null 参照 (Visual Basic では Nothing) の場合、MapPath メソッドは、現在のアプリケーションを格納しているディレクトリへの完全物理パスを返します。

注意に関するメモ注意 :

MapPath メソッドには、ホスト環境に関する機密情報が含まれている可能性があります。戻り値はユーザーに表示しないでください。

使用例

指定した Web サイトを格納する仮想ディレクトリの物理パスを返すコード例を次に示します。分離コード モジュールで MapPath を読み取るには、HttpContext.Current.Server.MapPath を使用します。

Dim FilePath As String
FilePath = Server.MapPath("/MyWebSite")
   
String FilePath;
FilePath = Server.MapPath("/MyWebSite");
   
String filePath;
filePath = get_Server().MapPath("/MyWebSite");
var filePath : String = Server.MapPath("/MyWebSite")
   

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HttpServerUtility クラス
HttpServerUtility メンバ
System.Web 名前空間