次の方法で共有


DirectoryNotFoundException コンストラクタ ()

メッセージ文字列がシステムによって提供されたメッセージに設定され、HRESULT が COR_E_DIRECTORYNOTFOUND に設定された DirectoryNotFoundException クラスの新しいインスタンスを初期化します。

名前空間: System.IO
アセンブリ: mscorlib (mscorlib.dll 内)

構文

'宣言
Public Sub New
'使用
Dim instance As New DirectoryNotFoundException
public DirectoryNotFoundException ()
public:
DirectoryNotFoundException ()
public DirectoryNotFoundException ()
public function DirectoryNotFoundException ()

解説

このコンストラクタは、新しいインスタンスの Exception.Message プロパティを、"指定されたディレクトリが見つかりせん。" などのエラーを説明するシステムから提供されるメッセージに初期化します。このメッセージは、システムの現在のカルチャを考慮して指定します。

新しいインスタンスの Exception.InnerException プロパティは、null 参照 (Visual Basic では Nothing) に初期化されます。

使用例

DirectoryNotFoundException コンストラクタを呼び出す方法を次のコード例に示します。

Imports System.IO

Module Module1
    Sub Main()
        Try

            ' Specify a directory name that does not exist for this demo.
            Dim dir As String = "c:\78fe9lk"

            ' If this directory does not exist, a DirectoryNotFoundException is thrown
            ' when attempting to set the current directory.
            Directory.SetCurrentDirectory(dir)

        Catch ex As System.IO.DirectoryNotFoundException

            ' Let the user know that the directory did not exist.
            Console.WriteLine("Directory not found: " + ex.Message)
        End Try
    End Sub
End Module

プラットフォーム

Windows 98, Windows 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

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

.NET Compact Framework

サポート対象 : 2.0、1.0

参照

関連項目

DirectoryNotFoundException クラス
DirectoryNotFoundException メンバ
System.IO 名前空間

その他の技術情報

ファイルおよびストリーム入出力
方法 : ファイルからテキストを読み取る
方法 : ファイルにテキストを書き込む