Table of Contents

Class FileSystemObserver

Namespace
RisingV.Shared.Files
Assembly
RisingV.Shared.dll

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 string

The root path to observe.

filter string

The file filter to apply (default is "*").

includeSubDirs bool

Whether 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 NotifyFilters

The 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 int

The 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

TimeSpan

Filter

public string Filter { get; }

Property Value

string

IncludeSubs

public bool IncludeSubs { get; }

Property Value

bool

RootPath

public string RootPath { get; }

Property Value

string

Methods

Dispose()

Disposes the FileSystemObserver and releases all resources.

public void Dispose()

Events

FilesChanged

public event EventHandler<FilesChangedEventArgs>? FilesChanged

Event Type

EventHandler<FilesChangedEventArgs>