Directory Watch
With the DirectoryWatch service, you can watch a directory for file changes, creations, renaming, and deletions.
You can add the logic you want to execute to the applicable service events.
Properties
Section titled “Properties ”Buffer Size
Section titled “Buffer Size ”You can set the buffer to 4 KB or larger, but it must not exceed 64 KB. If you try to set the buffer size property to less than 4096 bytes, your value is discarded and the buffer size property is set to 4096 bytes. For best performance, use a multiple of 4 KB on Intel-based computers.
Filter
Section titled “Filter ”Add a file mask to filter specific file types (e.g. *.txt).
If no value is specified, all files (*.*) will be watched.
Include Subdirectories
Section titled “Include Subdirectories ”A flag to indicate whether the service should process files in sub-folders of the specified path.
Notify Filter
Section titled “Notify Filter ”The types of changes to watch for. These options are only applicable when the “Watch for changes” property is true.
- Attributes: Occurs when a file or directory has been saved with changed attributes.
- Creation Time: Occurs when a file or directory is created.
- Directory Name: Occurs when a directory name has changed.
- File Name: Occurs when a filename has changed.
- Last Access: Occurs when a file is accessed.
- Last Write: Occurs when a file is overwritten or data is appended, as well as when a folder is written to.
- Security: Occurs when the security settings of a file or directory change.
- Size: Occurs when a file’s size changes.
The path of the directory to be watched.
Watch for Changes
Section titled “Watch for Changes ”Activates the ChangedEvent.
Watch for Creation
Section titled “Watch for Creation ”Activates the CreatedEvent.
Watch for Deletions
Section titled “Watch for Deletions ”Activates the DeletedEvent.
Watch for Renaming
Section titled “Watch for Renaming ”Activates the RenamedEvent.
Events
Section titled “Events ”ChangedEvent
Section titled “ChangedEvent ”Activated by the “Watch for changes” property. Raised when a file or directory has changed in the watched directory. Use the “Notify filter” property to specify the relevant changes to watch for.
CreatedEvent
Section titled “CreatedEvent ”Activated by the “Watch for creation” property. Raised when a file or directory has been created in the watched directory.
DeletedEvent
Section titled “DeletedEvent ”Activated by the “Watch for deletions” property. Raised when a file or directory has been deleted in the watched directory.
RenamedEvent
Section titled “RenamedEvent ”Activated by the “Watch for renaming” property. Raised when a file or directory has been renamed in the watched directory.
ErrorEvent
Section titled “ErrorEvent ”Raised when an error has occurred in the watched directory.