| 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.
| |
| CanRaiseEvents |
Gets a value indicating whether the component can raise an event.
(Inherited from Component.) | |
| Changed |
Occurs when a file or directory in the specified Path is changed.
| |
| Container |
Gets the IContainer that contains the Component.
(Inherited from Component.) | |
| Created |
Occurs when a file or directory in the specified Path is created.
| |
| CreateObjRef(Type) |
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.) | |
| Deleted |
Occurs when a file or directory in the specified Path is deleted.
| |
| DesignMode |
Gets a value that indicates whether the Component is currently in design mode.
(Inherited from Component.) | |
| Dispose(Boolean) |
Releases the unmanaged resources used by the FileSystemWatcher and optionally releases the managed resources.
(Overrides Component.Dispose(Boolean).) | |
| Dispose()()()() |
Releases all resources used by the Component.
(Inherited from Component.) | |
| Disposed |
Occurs when the component is disposed by a call to the Dispose()()()() method.
(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 FileSystemWatcher is reclaimed by garbage collection.
(Overrides Component.Finalize()()()().) | |
| GetHashCode()()()() |
Serves as a hash function for a particular type.
(Inherited from Object.) | |
| GetLifetimeService()()()() |
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.) | |
| GetService(Type) | (Inherited from Component.) | |
| 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.
| |
| InitializeLifetimeService()()()() |
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.) | |
| MemberwiseClone(Boolean) |
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.) | |
| 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()()()() |
Returns a String containing the name of the Component, if any. This method should not be overridden.
(Inherited from Component.) |
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 handle the Renamed event.
For a list of initial property values for an instance of FileSystemWatcher, see the FileSystemWatcher constructor. Please note that Hidden files are not ignored.| Platforms Supported | |
|---|---|
| Windows Mobile | Windows Mobile Version 2003 and later |
| Windows Embedded Compact | Windows Embedded Compact 4.2 and later |
| Object | |||
| MarshalByRefObject | |||
| Component | |||
| FileSystemWatcher | |||