Table of Contents

Class DirectoryWatcher

Namespace
Stride.Core.IO
Assembly
Stride.Core.IO.dll

Track file system events from several directories.

public class DirectoryWatcher : IDisposable
Inheritance
object
DirectoryWatcher
Implements
Extension Methods

Constructors

DirectoryWatcher(string?)

Initializes a new instance of the DirectoryWatcher class.

public DirectoryWatcher(string? fileFilter = null)

Parameters

fileFilter string

The file filter By default null default to .

Properties

FileFilter

Gets the file filter used by this instance.

public string FileFilter { get; }

Property Value

string

The file filter.

Methods

CreateFileSystemWatcher(string)

protected FileSystemWatcher CreateFileSystemWatcher(string directory)

Parameters

directory string

Returns

FileSystemWatcher

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

GetTrackedDirectories()

Gets a list of current directories being tracked.

public List<string> GetTrackedDirectories()

Returns

List<string>

A list of current directories being tracked

OnChangesMissed(object, ChangesMissedEventArgs)

Called when the watch of a directory started again after an error.

protected virtual void OnChangesMissed(object sender, ChangesMissedEventArgs e)

Parameters

sender object

The sender.

e ChangesMissedEventArgs

The directory whose changes may have been missed.

OnModified(object, FileEvent)

Called when a file event occurred.

protected virtual void OnModified(object sender, FileEvent e)

Parameters

sender object

The sender.

e FileEvent

The file event.

Track(string)

Tracks the specified path.

public void Track(string path)

Parameters

path string

The path.

Remarks

If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.

UnTrack(string)

UnTracks the specified path.

public void UnTrack(string path)

Parameters

path string

Remarks

If path is a file, this will used the parent directory. If the path is invalid, it will not fail but just skip it.

Events

ChangesMissed

Occurs when the watch of a directory failed and started again, for example after the buffer of its events overflowed: the changes in that directory in the meantime may never be reported by Modified.

public event EventHandler<ChangesMissedEventArgs>? ChangesMissed

Event Type

EventHandler<ChangesMissedEventArgs>

Remarks

It is raised once the new watch runs, so a listener that reads the files of the directory again then misses nothing; it can find what changed with a FileWriteTimes.

Modified

Occurs when a file/directory change occurred.

public event EventHandler<FileEvent>? Modified

Event Type

EventHandler<FileEvent>