← Interactive API Explorer
Namespace: System.IO

FileSystemWatcher

Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.

Properties (4)

String Path
Gets or sets the path of the directory to watch.
Value: The path to monitor. The default is an empty string ("").
String Filter
Gets or sets the filter string used to determine what files are monitored in a directory.
Value: The filter string. The default is "*.*" (Watches all files.)
bool IncludeSubdirectories
Gets or sets a value indicating whether subdirectories within the specified path should be monitored.
Value: true if you want to monitor subdirectories; otherwise, false. The default is false.
bool EnableRaisingEvents
Gets or sets a value indicating whether the component is enabled.
Value: true if the component is enabled; otherwise, false. The default is false. If you are using the component on a designer in Visual Studio 2005, the default is true.

Methods (2)

FileSystemWatcher(String)Constructor
Initializes a new instance of the FileSystemWatcher class, given the specified directory to monitor.
ParameterDescription
pathThe directory to monitor, in standard or Universal Naming Convention (UNC) notation.
FileSystemWatcher(String,String)Constructor
Initializes a new instance of the FileSystemWatcher class, given the specified directory and type of files to monitor.
ParameterDescription
pathThe directory to monitor, in standard or Universal Naming Convention (UNC) notation.
filterThe type of files to watch. For example, "*.txt" watches for changes to all text files.

Events (5)

event Created
Occurs when a file or directory in the specified Path is created.
event Deleted
Occurs when a file or directory in the specified Path is deleted.
event Changed
Occurs when a file or directory in the specified Path is changed.
event Renamed
Occurs when a file or directory in the specified Path is renamed.
event Error
Occurs when the instance of FileSystemWatcher is unable to continue monitoring changes or when the internal buffer overflows.