Class PollingFileObserver
Periodically scans a directory tree and reports file-level changes
public sealed class PollingFileObserver : IAsyncDisposable
- Inheritance
-
PollingFileObserver
- Implements
- Inherited Members
- Extension Methods
Constructors
PollingFileObserver(string, TimeSpan?, bool)
Initializes a new instance of the PollingFileObserver class.
public PollingFileObserver(string rootPath, TimeSpan? pollInterval = null, bool includeSubdirectories = true)
Parameters
rootPath
stringThe root path to observe for file changes.
pollInterval
TimeSpan?The interval at which to poll for changes. Defaults to 5 seconds.
includeSubdirectories
boolIf true, includes subdirectories in the observation. Defaults to true.
Exceptions
- DirectoryNotFoundException
Thrown if the specified root path does not exist.
Properties
IncludeSubdirs
public bool IncludeSubdirs { get; }
Property Value
PollInterval
public TimeSpan PollInterval { get; }
Property Value
RootPath
public string RootPath { get; }
Property Value
Methods
DisposeAsync()
Stops the file observer and releases resources.
public ValueTask DisposeAsync()
Returns
Start()
Starts the file observer.
public void Start()
Events
FilesChanged
Raised after each scan that detects ≥ 1 changes
public event EventHandler<FilesChangedEventArgs>? FilesChanged