FileNotFoundException 建構函式

定義

使用選擇性的訊息字串和內部 Exception 參考,初始化 FileNotFoundException 類別的新執行個體。

多載

FileNotFoundException()

使用將其訊息字串設定為系統提供的訊息,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException(String)

使用指定的錯誤訊息,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException(SerializationInfo, StreamingContext)
已淘汰.

使用指定的序列化及內容資訊,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException(String, String)

使用指定的錯誤訊息和無法找到的檔案名稱,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException(String, String, Exception)

使用指定的錯誤訊息、無法找到的檔案名稱和造成這個例外狀況原因的內部例外參考,初始化 FileNotFoundException 類別的新執行個體。

FileNotFoundException()

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

使用將其訊息字串設定為系統提供的訊息,初始化 FileNotFoundException 類別的新執行個體。

public:
 FileNotFoundException();
public FileNotFoundException ();
Public Sub New ()

備註

這個建構函式會將新實例的 屬性初始化 Message 為系統提供的訊息,描述錯誤,例如「找不到指定的檔案」。此訊息會將目前的系統文化特性納入考慮。

另請參閱

適用於

FileNotFoundException(String)

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

使用指定的錯誤訊息,初始化 FileNotFoundException 類別的新執行個體。

public:
 FileNotFoundException(System::String ^ message);
public FileNotFoundException (string message);
public FileNotFoundException (string? message);
new System.IO.FileNotFoundException : string -> System.IO.FileNotFoundException
Public Sub New (message As String)

參數

message
String

錯誤的描述。 message 的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

備註

這個建構函式會使用 message 初始化 Message 新實例的 屬性。

另請參閱

適用於

FileNotFoundException(SerializationInfo, StreamingContext)

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

警告

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

使用指定的序列化及內容資訊,初始化 FileNotFoundException 類別的新執行個體。

protected:
 FileNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected FileNotFoundException (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 FileNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.IO.FileNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.FileNotFoundException
[<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.FileNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.FileNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

物件,存放關於所擲回例外狀況的已序列化物件資料。

context
StreamingContext

物件,包含關於來源或目的端的內容資訊。

屬性

另請參閱

適用於

FileNotFoundException(String, Exception)

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 FileNotFoundException 類別的新執行個體。

public:
 FileNotFoundException(System::String ^ message, Exception ^ innerException);
public FileNotFoundException (string message, Exception innerException);
public FileNotFoundException (string? message, Exception? innerException);
new System.IO.FileNotFoundException : string * Exception -> System.IO.FileNotFoundException
Public Sub New (message As String, innerException As Exception)

參數

message
String

錯誤的描述。 message 的內容必須能讓人了解。 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。

innerException
Exception

做為目前例外狀況發生原因的例外狀況。 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。

備註

被擲回以做為前一個例外狀況直接結果的例外狀況,應該在 InnerException 屬性中包含對前一個例外狀況的參考。 InnerException 屬性傳回的值會與傳入建構函式的值相同,或傳回 null (如果 InnerException 屬性未提供內部例外狀況值給建構函式)。

下表顯示 FileNotFoundException 執行個體的初始屬性值。

屬性
InnerException 內部例外狀況參考。
Message 錯誤訊息字串。

如需內部例外狀況的詳細資訊,請參閱 InnerException

另請參閱

適用於

FileNotFoundException(String, String)

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

使用指定的錯誤訊息和無法找到的檔案名稱,初始化 FileNotFoundException 類別的新執行個體。

public:
 FileNotFoundException(System::String ^ message, System::String ^ fileName);
public FileNotFoundException (string message, string fileName);
public FileNotFoundException (string? message, string? fileName);
new System.IO.FileNotFoundException : string * string -> System.IO.FileNotFoundException
Public Sub New (message As String, fileName As String)

參數

message
String

錯誤的描述,或 null 以使用具有給定 fileName 的系統提供訊息。 message 的內容應能讓人了解。 這個建構函式的呼叫端必須確保這個字串已針對目前系統的文化特性當地語系化。

fileName
String

檔案的完整名稱,其具有無效的影像。

備註

建構函式會使用 初始化新實例的 屬性,並使用 來初始化 MessageFileName 屬性 fileNamemessage

另請參閱

適用於

FileNotFoundException(String, String, Exception)

來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs
來源:
FileNotFoundException.cs

使用指定的錯誤訊息、無法找到的檔案名稱和造成這個例外狀況原因的內部例外參考,初始化 FileNotFoundException 類別的新執行個體。

public:
 FileNotFoundException(System::String ^ message, System::String ^ fileName, Exception ^ innerException);
public FileNotFoundException (string message, string fileName, Exception innerException);
public FileNotFoundException (string? message, string? fileName, Exception? innerException);
new System.IO.FileNotFoundException : string * string * Exception -> System.IO.FileNotFoundException
Public Sub New (message As String, fileName As String, innerException As Exception)

參數

message
String

解釋例外狀況原因的錯誤訊息。

fileName
String

檔案的完整名稱,其具有無效的影像。

innerException
Exception

做為目前例外狀況發生原因的例外狀況。 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。

備註

被擲回以做為前一個例外狀況直接結果的例外狀況,應該在 InnerException 屬性中包含對前一個例外狀況的參考。 InnerException 屬性傳回的值會與傳入建構函式的值相同,或傳回 null (如果 InnerException 屬性未提供內部例外狀況值給建構函式)。

下表顯示 FileNotFoundException 執行個體的初始屬性值。

屬性
InnerException 內部例外狀況參考。
Message 錯誤訊息字串。

如需內部例外狀況的詳細資訊,請參閱 InnerException

另請參閱

適用於