Class FileWriteTimes
The last write time and the size of the files a listener of a DirectoryWatcher follows, to find which of them changed while the watcher missed changes (ChangesMissed).
public sealed class FileWriteTimes
- Inheritance
-
objectFileWriteTimes
- Extension Methods
Remarks
A listener records each file it follows, then each file its events are about, and replays the events Reconcile(string, IEnumerable<string>?) finds as if the watcher had sent them. A file that does not exist is recorded too, so that it is found when it comes back. The methods can be called from several threads.
Methods
Add(string)
Starts following a file: records its current state, unless it is followed already.
public bool Add(string path)
Parameters
pathstringThe path of the file.
Returns
- bool
trueif the file was not followed yet.
Contains(string)
Whether a file is followed.
public bool Contains(string path)
Parameters
pathstringThe path of the file.
Returns
IsUnder(string, string)
Whether a path is a directory or is in it, with the case of the paths of the file system of the platform.
public static bool IsUnder(string path, string directory)
Parameters
pathstringThe full path of a file or a directory.
directorystringThe full path of the directory.
Returns
Reconcile(string, IEnumerable<string>?)
Finds the files of a directory that changed since they were recorded, and records their current state.
public List<FileEvent> Reconcile(string directory, IEnumerable<string>? currentFiles = null)
Parameters
directorystringThe directory whose changes were missed, with its subdirectories.
currentFilesIEnumerable<string>Files there that may not be followed yet, such as the files of the directory a listener lists: a file that is not followed yet is created.
Returns
Update(string)
Records the current state of a file, after an event of the watcher about it.
public void Update(string path)
Parameters
pathstringThe path of the file.