FileSystemWatcher

The FileSystemWatcher component monitors the file system notifications and raises a notification event when a directory, or file in a directory, changes. You can use a FileSystemWatcher to look for changes in files or subdirectories in a specified directory on a local computer, network drive or remote computer.

The Filter property for the component can be set to empty ("") or a wildcard ("*.*") to watch for changes in all files. Watching a specific file is achieved with a Filter property set to the file name. Changes in certain types of files can be watched with an extension Filter - for example, "*.dat" to watch for changes in data files.

The NotifyFilter property for the component determines the kind of change to be watched. For example, changes in the LastWrite date and time, or the Size of files or directories can be watched with the NotifyFilter.

Renaming, deletion or creation of files or directories can be watched with the Changed, Created, Deleted and Renamed events and specific parameters.

Properties

The key properties for the FileSystemWatcher component include:

  • Filter. Specifies the filter used to determine what files are monitored in a directory.

  • NotifyFilter. Determines the type of changes that are to be watched for.

  • Path. Specifies the path of the directory to watch.

Events

The key events for the FileSystemWatcher component include:

  • Changed. Occurs when a file meeting the filter criteria in the specified path is changed.

  • Created. Occurs when a file meeting the filter criteria in the specified path is created.

  • Deleted. Occurs when a file meeting the filter criteria in the specified path is deleted.

  • Renamed. Occurs when a file meeting the filter criteria in the specified path is renamed.

For information on configuring events and other components of the design using a script, see: Working with Scripts.

Adding a FileSystemWatcher

When you drag a FileSystemWatcher component from the Toolbox to a form in the Flow Designer, it will appear as an entry in the design space. You can select the control and configure it using the Properties pane.

Importantly, use the Path field to set the location of the directory to be watched by the FileSystemWatcher component, and select the type of change to be monitored in the NotifyFilter field. Optionally, you can set a Filter to narrow the focus of the watch to a specific file or file type.

More information on the FileSystemWatcher component can be viewed at the link to Microsoft® Documentation.