Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ErrorEventArgs Class

Provides data for the Error event.

For a list of all members of this type, see ErrorEventArgs Members.

System.Object
   System.EventArgs
      System.IO.ErrorEventArgs

[Visual Basic]
Public Class ErrorEventArgs
   Inherits EventArgs
[C#]
public class ErrorEventArgs : EventArgs
[C++]
public __gc class ErrorEventArgs : public EventArgs
[JScript]
public class ErrorEventArgs extends EventArgs

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

ErrorEventArgs contains the Exception that caused the Error event. This class provides the GetException method to retrieve the exception.

Example

[Visual Basic, C#, C++] The following example creates a new instance of ErrorEventArgs and initializes it with an Exception. Then the example calls GetException to retrieve the Exception and display the error message. There is no form associated with this code.

[Visual Basic] 
Overloads Public Shared Sub Main(args() As String)
    ' Creates an exception with an error message.
    Dim myException As New Exception("This is an exception test")
    
    ' Creates an ErrorEventArgs with the exception.
    Dim myErrorEventArgs As New ErrorEventArgs(myException)
    
    ' Extracts the exception from the ErrorEventArgs and display it.
    Dim myReturnedException As Exception = myErrorEventArgs.GetException()
    MessageBox.Show(("The returned exception is: " & myReturnedException.Message))
End Sub 'Main

[C#] 
public static void Main(string[] args) {
    // Creates an exception with an error message.
    Exception myException= new Exception("This is an exception test");
 
    // Creates an ErrorEventArgs with the exception.
    ErrorEventArgs myErrorEventArgs = new ErrorEventArgs(myException);
 
    // Extracts the exception from the ErrorEventArgs and display it.
    Exception myReturnedException = myErrorEventArgs.GetException();
    MessageBox.Show("The returned exception is: " + myReturnedException.Message);
 }
    

[C++] 
int main() {
    // Creates an exception with an error message.
    Exception* myException= new Exception(S"This is an exception test");
 
    // Creates an ErrorEventArgs with the exception.
    ErrorEventArgs* myErrorEventArgs = new ErrorEventArgs(myException);
 
    // Extracts the exception from the ErrorEventArgs and display it.
    Exception* myReturnedException = myErrorEventArgs->GetException();
    MessageBox::Show(String::Concat( S"The returned exception is: ", myReturnedException->Message ));
}
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.IO

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

ErrorEventArgs Members | System.IO Namespace | ErrorEventHandler | FileSystemWatcher | OnError

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.