ErrorEventArgs Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Provides data for the FileSystemWatcher::Error event.

Namespace:   System.IO
Assembly:  System (in System.dll)


public ref class ErrorEventArgs : EventArgs


Initializes a new instance of the ErrorEventArgs class.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Gets the Exception that represents the error that occurred.


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

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

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.

int main()

   // Creates an exception with an error message.
   Exception^ myException = gcnew Exception( "This is an exception test" );

   // Creates an ErrorEventArgs with the exception.
   ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException );

   // Extracts the exception from the ErrorEventArgs and display it.
   Exception^ myReturnedException = myErrorEventArgs->GetException();
   MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) );

The following example shows how to create a FileSystemWatcher to monitor file changes (creates, deletes, renames, changes) occurring on a disk drive. The example also shows how to properly receive error notifications.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1

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

Return to top