Class DirectoryWatcher
Track file system events from several directories.
public class DirectoryWatcher : IDisposable
- Inheritance
-
DirectoryWatcher
- Implements
- Extension Methods
Constructors
DirectoryWatcher(string)
Initializes a new instance of the DirectoryWatcher class.
public DirectoryWatcher(string fileFilter = null)
Parameters
fileFilter
stringThe 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
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public virtual void Dispose()
GetTrackedDirectories()
Gets a list of current directories being tracked.
public List<string> GetTrackedDirectories()
Returns
OnModified(object, FileEvent)
Called when a file event occurred.
protected virtual void OnModified(object sender, FileEvent e)
Parameters
Track(string)
Tracks the specified path.
public void Track(string path)
Parameters
path
stringThe 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
Modified
Occurs when a file/directory change occurred.
public event EventHandler<FileEvent> Modified