System Watcher. Error Event
Occurs when the instance of FileSystemWatcher is unable to continue monitoring changes or when the internal buffer overflows.
public: event System::IO::ErrorEventHandler ^ Error;
public event System.IO.ErrorEventHandler? Error;
public event System.IO.ErrorEventHandler Error;
[System.ComponentModel.Browsable(false)] public event System.IO.ErrorEventHandler Error;
member this.Error : System.IO.ErrorEventHandler
[<System.ComponentModel.Browsable(false)>] member this.Error : System.IO.ErrorEventHandler
Public Custom Event Error As ErrorEventHandler
This event is raised whenever something prevents the FileSystemWatcher object from monitoring changes. For example, if the object is monitoring changes in a remote directory and the connection to that directory is lost, the Error event is raised.
The system notifies you of file changes, and it stores those changes in a buffer that the component creates and passes to the APIs. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer is expensive, because it comes from non paged memory that cannot be swapped out to disk, so keep the buffer as small as possible. To avoid a buffer overflow, use the NotifyFilter, Filter, and IncludeSubdirectories properties to filter out unwanted change notifications.
Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.