Table of Contents

Class DirectoryWatcher

Namespace
RadioExt_Helper.utility
Assembly
RadioExt-Helper.dll
Encapsulates a FileSystemWatcher to watch a directory for changes. Subscribe to events to be notified when files are changed, created, deleted, or renamed.
public class DirectoryWatcher
Inheritance
DirectoryWatcher
Inherited Members

Constructors

DirectoryWatcher(string, TimeSpan)

Create a new instance of DirectoryWatcher to watch the specified directory for changes.
public DirectoryWatcher(string watchPath, TimeSpan timeWindow)

Parameters

watchPath string
The path to watch for changes.
timeWindow TimeSpan
The time window to wait before processing another event in the same directory.

Exceptions

ArgumentNullException
Occurs when the watchPath is null or empty.
ArgumentException
Occurs if the directory specified by watchPath does not exist.

Methods

Start()

Start watching the directory for changes.
public void Start()

Stop()

Stop watching the directory for changes.
public void Stop()

Events

Error

Occurs when the file system watcher encounters an error.
public event EventHandler<Exception>? Error

Event Type

EventHandler<Exception>

FileChanged

Occurs when a file in the watched directory is changed.
public event EventHandler<string>? FileChanged

Event Type

EventHandler<string>

FileCreated

Occurs when a file is created in the watched directory.
public event EventHandler<string>? FileCreated

Event Type

EventHandler<string>

FileDeleted

Occurs when a file is deleted from the watched directory.
public event EventHandler<string>? FileDeleted

Event Type

EventHandler<string>

FileRenamed

Occurs when a file is renamed in the watched directory. Event data includes the old and new file paths.
public event EventHandler<(string OldPath, string NewPath)>? FileRenamed

Event Type

EventHandler<(string OldPath, string NewPath)>