NotifyFilters.DirectoryName Or NotifyFilters.FileName Or NotifyFilters.LastAccess Or Watcher.NotifyFilter = NotifyFilters.Attributes Or NotifyFilters.CreationTime Or ' Watch for all changes specified in the NotifyFilters ' Create a new FileSystemWatcher and set its properties. ' Display the proper way to call the program.Ĭonsole.WriteLine( "Usage: FileWatcher.exe ")Ĭonsole.WriteLine( "Press any key to continue") ' If a directory is not specified, exit program. Public Shared Sub Main( ByVal args As String()) The FileSystemWatcher class raises the events described below.įired when a file or directory in the watched path is changedįired when a file or directory in the watched path is createdįired when a file or directory in the watched path is deletedįired when the internal buffer overflows due to many changes made over a short time, particularly when the buffer size is smallįired when a file or directory in the watched path is renamedīelow code Illustrates the use of the FileSystemWatcher class to capture changes to files and directories and report them on the console screen. You can also fine-tune FileSystemWatcher to monitor any change in file Attributes, LastAccess, LastWrite, Security, and Size data. The option to monitor files with specific extensions can be set using the Filter property of the FileSystemWatcher class. (Only remote machines running Windows NT or Windows 2000 are supported at present.) If you have Windows 2000, you can even monitor a remote system for changes. The class can monitor changes to subdirectories and files within the specified directory. You must specify a directory to be monitored. Another very useful class, FileSystemWatcher, acts as a watchdog for file system changes and raises an event when a change occurs.
0 Comments
Leave a Reply. |