Class FileSystemObserver
Thin, debounced wrapper around FileSystemWatcher.
public sealed class FileSystemObserver : IDisposable
- Inheritance
-
FileSystemObserver
- Implements
- Inherited Members
- Extension Methods
Constructors
FileSystemObserver(string, string, bool, Func<string, bool>?, NotifyFilters, TimeSpan?, int)
Initializes a new instance of the FileSystemObserver class.
public FileSystemObserver(string rootPath, string filter = "*", bool includeSubDirs = true, Func<string, bool>? pathFilter = null, NotifyFilters notifyFilters = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite | NotifyFilters.CreationTime, TimeSpan? debounce = null, int internalBuffer = 65536)
Parameters
rootPath
stringThe root path to observe.
filter
stringThe file filter to apply (default is "*").
includeSubDirs
boolWhether to include subdirectories in the observation (default is true).
pathFilter
Func<string, bool>Optional filter function to apply to the paths of changes. If provided, only paths that return true will be processed.
notifyFilters
NotifyFiltersThe notify filters to apply (default includes file name, directory name, last write time, and creation time).
debounce
TimeSpan?The debounce time to wait before triggering the event after a change (default is 100 milliseconds).
internalBuffer
intThe internal buffer size for the file system watcher (default is 64 kB).
Exceptions
- DirectoryNotFoundException
Thrown if the specified root path does not exist.
Properties
Debounce
public TimeSpan Debounce { get; }
Property Value
Filter
public string Filter { get; }
Property Value
IncludeSubs
public bool IncludeSubs { get; }
Property Value
RootPath
public string RootPath { get; }
Property Value
Methods
Dispose()
Disposes the FileSystemObserver and releases all resources.
public void Dispose()
Events
FilesChanged
public event EventHandler<FilesChangedEventArgs>? FilesChanged