| C# | Visual Basic |
public sealed class FileSystemWatcher : Component, IDisposable
Public NotInheritable Class FileSystemWatcher _ Inherits Component _ Implements IDisposable
| All Members | Constructors | Methods | Properties | Events | |
| Icon | Member | Description |
|---|---|---|
| FileSystemWatcher()()() |
Initializes a new instance of the FileSystemWatcher class.
| |
| FileSystemWatcher(String) |
Initializes a new instance of the FileSystemWatcher class, given the specified directory to monitor.
| |
| FileSystemWatcher(String, String) |
Initializes a new instance of the FileSystemWatcher class, given the specified directory and type of files to monitor.
| |
| Changed |
Occurs when a file or directory in the specified Path is changed.
| |
| Created |
Occurs when a file or directory in the specified Path is created.
| |
| Deleted |
Occurs when a file or directory in the specified Path is deleted.
| |
| Dispose()()() | Releases all resources used by the Component. (Inherited from Component.) | |
| Dispose(Boolean) | Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.) | |
| Disposed | Adds an event handler to listen to the Disposed event on the component. (Inherited from Component.) | |
| EnableRaisingEvents |
Gets or sets a value indicating whether the component is enabled.
| |
| Equals(Object) | (Inherited from Object.) | |
| Events | Gets the list of event handlers that are attached to this Component. (Inherited from Component.) | |
| Filter |
Gets or sets the filter string, used to determine what files are monitored in a directory.
| |
| Finalize()()() | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.) | |
| GetHashCode()()() | Serves as a hash function for a particular type. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) | |
| GetType()()() | Gets the Type of the current instance. (Inherited from Object.) | |
| IncludeSubdirectories |
Gets or sets a value indicating whether subdirectories within the specified path should be monitored.
| |
| MemberwiseClone()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| NotifyFilter |
Gets or sets the type of changes to watch for.
| |
| Path |
Gets or sets the path of the directory to watch.
| |
| Renamed |
Occurs when a file or directory in the specified Path is renamed.
| |
| Site | (Inherited from Component.) | |
| ToString()()() | (Inherited from Object.) |
Use FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. You can create a component to watch files on a local computer, a network drive, or a remote computer.
To watch for changes in all files, set the Filter property to an empty string ("") or use wildcards ("*.*"). To watch a specific file, set the Filter property to the file name. For example, to watch for changes in the file MyDoc.txt, set the Filter property to "MyDoc.txt". You can also watch for changes in a certain type of file. For example, to watch for changes in text files, set the Filter property to "*.txt".
There are several types of changes you can watch for in a directory or file. For example, you can watch for changes in Attributes, the LastWrite date and time, or the Size of files or directories. This is done by setting the NotifyFilter property to one of the NotifyFilters values. For more information on the type of changes you can watch, see NotifyFilters.
You can watch for renaming, deletion, or creation of files or directories. For example, to watch for renaming of text files, set the Filter property to "*.txt" and call the WaitForChanged method with a Renamed specified for its parameter.
For a list of initial property values for an instance of FileSystemWatcher, see the FileSystemWatcher constructor. Please note that Hidden files are not ignored.| Object | |||
| MarshalByRefObject | |||
| Component | |||
| FileSystemWatcher | |||