Thursday, June 2, 2016

FileSystemWatcher Class DRAFT!!! NOT COMPLETE!!!

Occasionally you may have a folder (network, local, ftp, etc) where you want to be alerted when a file is received or changed so that you may act on it (processes it, email it, archive it). This can ba done with the FileSystemWatcher Class. It "Listens to the file system change notifications and raises event when directory or a file in a directory is changed ". It works on directories or sub-directories on a local, drive, network drive or 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".

See example below: Notice the timestamp on the file "TestFile.txt" in the folder "C:\TestFolder" below.


No comments:

Post a Comment