示例#1
0
        protected MediaFileWatcher()
        {
            watcher        = new FileSystemWatcher();
            MediaFileState = new MediaFileState();

            // Watch for changes in LastAccess and LastWrite times, and
            //the renaming of files or directories.
            //watcher.NotifyFilter = (NotifyFilters)(NotifyFilters.LastAccess |
            //    NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Attributes);

            watcher.NotifyFilter = (NotifyFilters)(NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Attributes);

            // Only watch text files.
            watcher.Filter = "*.*";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(FileChanged);
            watcher.Created += new FileSystemEventHandler(FileCreated);
            watcher.Deleted += new FileSystemEventHandler(FileDeleted);
            watcher.Renamed += new System.IO.RenamedEventHandler(FileRenamed);

            fileWatcherQueue = new MediaFileWatcherQueue(this);

            DebugOutput = false;
        }
示例#2
0
        protected MediaFileWatcher()
        {
            watcher = new FileSystemWatcher();
            MediaFileState = new MediaFileState();
                               
            // Watch for changes in LastAccess and LastWrite times, and 
            //the renaming of files or directories. 
            //watcher.NotifyFilter = (NotifyFilters)(NotifyFilters.LastAccess |
            //    NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Attributes);

            watcher.NotifyFilter = (NotifyFilters)(NotifyFilters.LastWrite | NotifyFilters.FileName |  NotifyFilters.Attributes);

            // Only watch text files.
            watcher.Filter = "*.*";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(FileChanged);
            watcher.Created += new FileSystemEventHandler(FileCreated);
            watcher.Deleted += new FileSystemEventHandler(FileDeleted);
            watcher.Renamed += new System.IO.RenamedEventHandler(FileRenamed);

            fileWatcherQueue = new MediaFileWatcherQueue(this);

            DebugOutput = false;
         
        }