Class RestartableFileWatcher
Listens to the file system change notifications and raises events when a directory, or file in a directory, changes. Can be configured to restart at a given interval in case the FileWatcher loses contact with the folder (like network shared folder). Ordinary FileWatchers just quit.
Inheritance
Implements
Inherited Members
Namespace: ImageVault.Core.Lib.IO
Assembly: ImageVault.Core.dll
Syntax
public sealed class RestartableFileWatcher : IDisposable
Constructors
RestartableFileWatcher()
Declaration
public RestartableFileWatcher()
Properties
EnableRaisingEvents
Gets or sets a value indicating whether the component is enabled.
Declaration
public bool EnableRaisingEvents { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the component is enabled; otherwise, false. The default is false. If you are using the component on a designer in Visual Studio 2005, the default is true. |
Exceptions
Type | Condition |
---|---|
System.ObjectDisposedException | The RestartableFileWatcher object has been disposed. |
System.PlatformNotSupportedException | The current operating system is not Microsoft Windows NT or later. |
System.IO.FileNotFoundException | The directory specified in Path could not be found. |
System.ArgumentException | Path has not been set or is invalid. |
EnableRestart
Get/Sets the EnableRestart of the RestartableFileWatcher
Declaration
public bool EnableRestart { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | If the watcher should restart at a given interval. Default is false |
Filter
Gets or sets the filter string used to determine what files are monitored in a directory.
Declaration
public string Filter { get; set; }
Property Value
Type | Description |
---|---|
System.String | The filter string. The default is "." (Watches all files.) |
IncludeSubdirectories
Gets or sets a value indicating whether subdirectories within the specified path should be monitored.
Declaration
public bool IncludeSubdirectories { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if you want to monitor subdirectories; otherwise, false. The default is false. |
InternalBufferSize
Gets or sets the size of the internal buffer.
Declaration
public int InternalBufferSize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The internal buffer size. The default is 8192 (8 KB). |
NotifyFilter
Gets or sets the type of changes to watch for.
Declaration
public NotifyFilters NotifyFilter { get; set; }
Property Value
Type | Description |
---|---|
System.IO.NotifyFilters | One of the NotifyFilters values. The default is the bitwise OR combination of LastWrite, FileName, and DirectoryName. |
Path
Gets or sets the path of the directory to watch.
Declaration
public string Path { get; set; }
Property Value
Type | Description |
---|---|
System.String | The path to monitor. The default is an empty string (""). |
RestartTimeout
Get/Sets the RestartTimeout of the RestartableFileWatcher
Declaration
public TimeSpan RestartTimeout { get; set; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
Methods
Dispose()
Releases the resources used by the RestartableFileWatcher.
Declaration
public void Dispose()
Finalize()
Releases unmanaged resources and performs other cleanup operations before the RestartableFileWatcher is reclaimed by garbage collection.
Declaration
protected void Finalize()
Events
Created
Fires when an item is created
Declaration
public event FileSystemEventHandler Created
Event Type
Type | Description |
---|---|
System.IO.FileSystemEventHandler |
Deleted
Fires when a file is deleted
Declaration
public event FileSystemEventHandler Deleted
Event Type
Type | Description |
---|---|
System.IO.FileSystemEventHandler |
Error
If an error occurs, then this event is invoked
Declaration
public event ErrorEventHandler Error
Event Type
Type | Description |
---|---|
System.IO.ErrorEventHandler |
Renamed
Fires when an item is changed
Declaration
public event RenamedEventHandler Renamed
Event Type
Type | Description |
---|---|
System.IO.RenamedEventHandler |