IOException Constructors

Definition

使用其訊息字串,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with its message string.

Overloads

IOException()

初始化 IOException 類別的新執行個體,並將其訊息字串設定為空字串 ("")、其 HRESULT 設定為 COR_E_IO 及其內部例外狀況設定為 Null 參考。Initializes a new instance of the IOException class with its message string set to the empty string (""), its HRESULT set to COR_E_IO, and its inner exception set to a null reference.

IOException(String)

初始化 IOException 類別的新執行個體,並將其訊息字串設定為 message、將其 HRESULT 設定為 COR_E_IO 及將其內部例外狀況設定為 nullInitializes a new instance of the IOException class with its message string set to message, its HRESULT set to COR_E_IO, and its inner exception set to null.

IOException(SerializationInfo, StreamingContext)

使用指定的序列化及內容資訊,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with the specified serialization and context information.

IOException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況之內部例外狀況的參考,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with a specified error message and a reference to the inner exception that is the cause of this exception.

IOException(String, Int32)

將其訊息字串設定為 message 並將其 HRESULT 設定為使用者定義,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with its message string set to message and its HRESULT user-defined.

IOException()

初始化 IOException 類別的新執行個體,並將其訊息字串設定為空字串 ("")、其 HRESULT 設定為 COR_E_IO 及其內部例外狀況設定為 Null 參考。Initializes a new instance of the IOException class with its message string set to the empty string (""), its HRESULT set to COR_E_IO, and its inner exception set to a null reference.

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

Remarks

此函式會將新實例的 Message 屬性初始化為描述錯誤的系統提供訊息,例如「執行要求的作業時發生 i/o 錯誤」。The constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An I/O error occurred while performing the requested operation." 此訊息會考慮到目前系統的文化特性。This message takes into account the current system culture.

See also

IOException(String)

初始化 IOException 類別的新執行個體,並將其訊息字串設定為 message、將其 HRESULT 設定為 COR_E_IO 及將其內部例外狀況設定為 nullInitializes a new instance of the IOException class with its message string set to message, its HRESULT set to COR_E_IO, and its inner exception set to null.

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

Parameters

message
String

描述錯誤的 StringA String that describes the error. message 的內容必須能讓人了解。The content of message is intended to be understood by humans. 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

Remarks

此函式會使用 message初始化新實例的 Message 屬性。The constructor initializes the Message property of the new instance using message.

See also

IOException(SerializationInfo, StreamingContext)

使用指定的序列化及內容資訊,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with the specified serialization and context information.

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

Parameters

info
SerializationInfo

用於序列化或還原序列化物件的資料。The data for serializing or deserializing the object.

context
StreamingContext

物件的來源和目的端。The source and destination for the object.

See also

IOException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況之內部例外狀況的參考,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 IOException(System::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)

Parameters

message
String

說明例外狀況原因的錯誤訊息。The error message that explains the reason for the exception.

innerException
Exception

造成目前例外狀況的例外狀況。The exception that is the cause of the current exception. 如果 innerException 參數不是 null,則目前的例外狀況會在處理內部例外的 catch 區塊中引發。If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Remarks

當作先前例外狀況直接結果擲回的例外狀況應在 InnerException 屬性中包含先前例外狀況的參考。An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. InnerException 屬性傳回的值會與傳入建構函式的值相同,或傳回 null (如果 InnerException 屬性未提供內部例外狀況值給建構函式)。The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

下表顯示 IOException 執行個體的初始屬性值。The following table shows the initial property values for an instance of IOException.

屬性Property Value
InnerException 內部例外狀況參考。The inner exception reference.
Message 錯誤訊息字串。The error message string.

如需內部例外狀況的詳細資訊,請參閱 InnerExceptionFor more information on inner exceptions, see InnerException.

See also

IOException(String, Int32)

將其訊息字串設定為 message 並將其 HRESULT 設定為使用者定義,初始化 IOException 類別的新執行個體。Initializes a new instance of the IOException class with its message string set to message and its HRESULT user-defined.

public:
 IOException(System::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)

Parameters

message
String

描述錯誤的 StringA String that describes the error. message 的內容必須能讓人了解。The content of message is intended to be understood by humans. 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

hresult
Int32

識別所發生錯誤的整數。An integer identifying the error that has occurred.

See also

Applies to