DirectoryNotFoundException コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メッセージ文字列を使用して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| DirectoryNotFoundException() |
メッセージ文字列をシステム指定のメッセージに設定し、HRESULT を COR_E_DIRECTORYNOTFOUND に設定して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。 |
| DirectoryNotFoundException(String) |
メッセージ文字列を |
| DirectoryNotFoundException(SerializationInfo, StreamingContext) |
古い.
指定したシリアル化とコンテキスト情報を使用して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。 |
| DirectoryNotFoundException(String, Exception) |
指定したエラー メッセージと、この例外の原因である内部例外への参照を使用して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。 |
DirectoryNotFoundException()
メッセージ文字列をシステム指定のメッセージに設定し、HRESULT を COR_E_DIRECTORYNOTFOUND に設定して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。
public:
DirectoryNotFoundException();
public DirectoryNotFoundException();
Public Sub New ()
例
次のコード例は、 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
注釈
このコンストラクターは、新しいインスタンスの Exception.Message プロパティを、"指定されたディレクトリが見つかりませんでした" などのエラーを説明するシステム指定のメッセージに初期化します。このメッセージでは、現在のシステム カルチャが考慮されます。
新しいインスタンスの Exception.InnerException プロパティは、 nullに初期化されます。
こちらもご覧ください
適用対象
DirectoryNotFoundException(String)
メッセージ文字列を message に設定し、HRESULT を COR_E_DIRECTORYNOTFOUND に設定して、DirectoryNotFoundException クラスの新しいインスタンスを初期化します。
public:
DirectoryNotFoundException(System::String ^ message);
public DirectoryNotFoundException(string message);
public DirectoryNotFoundException(string? message);
new System.IO.DirectoryNotFoundException : string -> System.IO.DirectoryNotFoundException
Public Sub New (message As String)
パラメーター
- message
- String
エラーを説明する String 。
messageの内容は、人間が理解することを意図しています。 このコンストラクターの呼び出し元は、この文字列が現在のシステム カルチャ用にローカライズされていることを確認する必要があります。
注釈
このコンストラクターは、messageを使用して新しいインスタンスのException.Message プロパティを初期化します。
新しいインスタンスの Exception.InnerException プロパティは、 nullに初期化されます。
こちらもご覧ください
適用対象
DirectoryNotFoundException(SerializationInfo, StreamingContext)
注意事項
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
指定したシリアル化とコンテキスト情報を使用して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。
protected:
DirectoryNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected DirectoryNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
protected DirectoryNotFoundException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)
パラメーター
- info
- SerializationInfo
スローされる例外に関するシリアル化されたオブジェクト データを保持する SerializationInfo。
- context
- StreamingContext
ソースまたは宛先に関するコンテキスト情報を含む StreamingContext。
- 属性
こちらもご覧ください
適用対象
DirectoryNotFoundException(String, Exception)
指定したエラー メッセージと、この例外の原因である内部例外への参照を使用して、 DirectoryNotFoundException クラスの新しいインスタンスを初期化します。
public:
DirectoryNotFoundException(System::String ^ message, Exception ^ innerException);
public DirectoryNotFoundException(string message, Exception innerException);
public DirectoryNotFoundException(string? message, Exception? innerException);
new System.IO.DirectoryNotFoundException : string * Exception -> System.IO.DirectoryNotFoundException
Public Sub New (message As String, innerException As Exception)
パラメーター
- message
- String
例外の理由を説明するエラー メッセージ。
- innerException
- Exception
現在の例外の原因である例外。
innerException パラメーターがnullされていない場合、内部例外を処理するcatch ブロックで現在の例外が発生します。
注釈
前の例外の直接の結果としてスローされる例外は、 InnerException プロパティに前の例外への参照を含める必要があります。
InnerException プロパティは、コンストラクターに渡されるのと同じ値を返します。または、null プロパティがコンストラクターに内部例外値を提供しない場合はInnerExceptionします。
次の表に、 DirectoryNotFoundExceptionのインスタンスの初期プロパティ値を示します。
| 財産 | 価値 |
|---|---|
| InnerException | 内部例外参照。 |
| Message | エラー メッセージ文字列。 |