DirectoryNotFoundException クラス

定義

ファイルまたはディレクトリの一部が見つからない場合にスローされる例外。

public ref class DirectoryNotFoundException : System::IO::IOException
public class DirectoryNotFoundException : System.IO.IOException
[System.Serializable]
public class DirectoryNotFoundException : System.IO.IOException
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class DirectoryNotFoundException : System.IO.IOException
type DirectoryNotFoundException = class
    inherit IOException
[<System.Serializable>]
type DirectoryNotFoundException = class
    inherit IOException
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type DirectoryNotFoundException = class
    inherit IOException
Public Class DirectoryNotFoundException
Inherits IOException
継承
DirectoryNotFoundException
継承
DirectoryNotFoundException
属性

次の例は、 から強制的に回復する方法を DirectoryNotFoundException示しています。

using System;
using System.IO;

class Program
{

    static void Main(string[] args)
    {
        try
        {

            //  Specify a directory name that does not exist for this demo.
            string dir = @"c:\78fe9lk";

            // If this directory does not exist, a DirectoryNotFoundException is thrown
            // when attempting to set the current directory.
            Directory.SetCurrentDirectory(dir);
        }
        catch (DirectoryNotFoundException dirEx)
        {
            // Let the user know that the directory did not exist.
            Console.WriteLine("Directory not found: " + dirEx.Message);
        }
    }
}
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

注釈

DirectoryNotFoundException は、値が0x80070003を持つ HRESULT COR_E_DIRECTORYNOTFOUNDを使用します。 DirectoryNotFoundExceptionまた、COM 相互運用プログラムで HRESULT STG_E_PATHNOTFOUNDが表示され、値が0x80030003場合にもがスローされることに注意してください。

コンストラクター

DirectoryNotFoundException()

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

DirectoryNotFoundException(SerializationInfo, StreamingContext)

指定したシリアル化とコンテキスト情報を使用して、DirectoryNotFoundException クラスの新しいインスタンスを初期化します。

DirectoryNotFoundException(String)

メッセージ文字列を message に設定し、HRESULT を COR_E_DIRECTORYNOTFOUND に設定して、DirectoryNotFoundException クラスの新しいインスタンスを初期化します。

DirectoryNotFoundException(String, Exception)

指定したエラー メッセージおよびこの例外の原因となった内部例外への参照を使用して、DirectoryNotFoundException クラスの新しいインスタンスを初期化します。

プロパティ

Data

例外に関する追加のユーザー定義情報を提供する、キーと値のペアのコレクションを取得します。

(継承元 Exception)
HelpLink

この例外に関連付けられているヘルプ ファイルへのリンクを取得または設定します。

(継承元 Exception)
HResult

特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。

(継承元 Exception)
InnerException

現在の例外の原因となる Exception インスタンスを取得します。

(継承元 Exception)
Message

現在の例外を説明するメッセージを取得します。

(継承元 Exception)
Source

エラーの原因となるアプリケーションまたはオブジェクトの名前を取得または設定します。

(継承元 Exception)
StackTrace

呼び出し履歴で直前のフレームの文字列形式を取得します。

(継承元 Exception)
TargetSite

現在の例外がスローされたメソッドを取得します。

(継承元 Exception)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetBaseException()

派生クラスでオーバーライドされた場合、それ以後に発生する 1 つ以上の例外の根本原因である Exception を返します。

(継承元 Exception)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetObjectData(SerializationInfo, StreamingContext)

派生クラスでオーバーライドされた場合は、その例外に関する情報を使用して SerializationInfo を設定します。

(継承元 Exception)
GetType()

現在のインスタンスのランタイム型を取得します。

(継承元 Exception)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在の例外の文字列形式を作成して返します。

(継承元 Exception)

イベント

SerializeObjectState
古い.

例外がシリアル化され、例外に関するシリアル化されたデータを含む例外状態オブジェクトが作成されたときに発生します。

(継承元 Exception)

適用対象

こちらもご覧ください