IOException 建構函式

定義

使用其訊息字串,初始化 IOException 類別的新執行個體。

多載

IOException()

初始化 IOException 類別的新執行個體,並將其訊息字串設定為空字串 ("")、其 HRESULT 設定為 COR_E_IO 及其內部例外狀況設定為 Null 參考。

IOException(String)

初始化 IOException 類別的新執行個體,並將其訊息字串設定為 message、將其 HRESULT 設定為 COR_E_IO 及將其內部例外狀況設定為 null

IOException(SerializationInfo, StreamingContext)
已淘汰.

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

IOException(String, Exception)

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

IOException(String, Int32)

將其訊息字串設定為 message 並將其 HRESULT 設定為使用者定義,初始化 IOException 類別的新執行個體。

IOException()

初始化 IOException 類別的新執行個體,並將其訊息字串設定為空字串 ("")、其 HRESULT 設定為 COR_E_IO 及其內部例外狀況設定為 Null 參考。

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

備註

建構函式會將新實例的 屬性初始化 Message 為描述錯誤的系統提供訊息,例如「執行要求的作業時發生 I/O 錯誤」。此訊息會將目前的系統文化特性納入考慮。

另請參閱

適用於

IOException(String)

初始化 IOException 類別的新執行個體,並將其訊息字串設定為 message、將其 HRESULT 設定為 COR_E_IO 及將其內部例外狀況設定為 null

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

參數

message
String

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

備註

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

另請參閱

適用於

IOException(SerializationInfo, StreamingContext)

警告

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

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

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

參數

info
SerializationInfo

用於序列化或還原序列化物件的資料。

context
StreamingContext

物件的來源和目的端。

屬性

另請參閱

適用於

IOException(String, Exception)

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

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

參數

message
String

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

innerException
Exception

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

備註

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

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

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

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

另請參閱

適用於

IOException(String, Int32)

將其訊息字串設定為 message 並將其 HRESULT 設定為使用者定義,初始化 IOException 類別的新執行個體。

public:
 IOException(System::String ^ message, int hresult);
public IOException (string message, int hresult);
public IOException (string? message, int hresult);
new System.IO.IOException : string * int -> System.IO.IOException
Public Sub New (message As String, hresult As Integer)

參數

message
String

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

hresult
Int32

識別所發生錯誤的整數。

另請參閱

適用於