FileWatcher
Pennington.Infrastructure
Manages FileSystemWatcher instances and notifies subscribers of changes.
Constructors
FileWatcher
#public FileWatcher(IFileSystem fileSystem, ILogger<FileWatcher> logger = null)
Initializes the watcher with a filesystem abstraction and optional logger.
Parameters
fileSystemIFileSystemloggerILogger<FileWatcher>
Methods
AddPathWatch
#public void AddPathWatch(string path, string filePattern, Action<string, WatcherChangeTypes> onFileChanged, bool includeSubdirectories = true)
Watch a path for file changes matching a pattern.
Parameters
pathstringfilePatternstringonFileChangedAction<string, WatcherChangeTypes>includeSubdirectoriesbool
Dispose
#public void Dispose()
SubscribeToChanges
#public void SubscribeToChanges(Action onUpdate)
Subscribe to be notified when any watched file changes.
Parameters
onUpdateAction
SubscribeToChanges
#public void SubscribeToChanges(Action<FileChangeNotification> onUpdate)
Subscribe to be notified when any watched file changes, with the changed path and change type.
Parameters
onUpdateAction<FileChangeNotification>
Pennington.Infrastructure.FileWatcher
namespace Pennington.Infrastructure;
/// Manages FileSystemWatcher instances and notifies subscribers of changes.
public class FileWatcher
{
/// Watch a path for file changes matching a pattern.
public void AddPathWatch(string path, string filePattern, Action<string, WatcherChangeTypes> onFileChanged, bool includeSubdirectories = true)
;
public void Dispose()
;
/// Initializes the watcher with a filesystem abstraction and optional logger.
public FileWatcher(IFileSystem fileSystem, ILogger<FileWatcher> logger = null)
;
/// Subscribe to be notified when any watched file changes.
public void SubscribeToChanges(Action onUpdate)
;
/// Subscribe to be notified when any watched file changes, with the changed path and change type.
public void SubscribeToChanges(Action<FileChangeNotification> onUpdate)
;
}