Пример #1
0
        public WatcherEx(string filePath, string searchCriteria, bool includeSubfolder, int interval)
        {
            WatcherInfo info = new WatcherInfo();

            info.ChangesFilters = NotifyFilters.Attributes |
                                  NotifyFilters.CreationTime |
                                  NotifyFilters.DirectoryName |
                                  NotifyFilters.FileName |
                                  NotifyFilters.LastAccess |
                                  NotifyFilters.LastWrite |
                                  NotifyFilters.Security |
                                  NotifyFilters.Size;

            info.IncludeSubFolders   = includeSubfolder;
            info.WatchesFilters      = WatcherChangeTypes.All;
            info.WatchForDisposed    = true;
            info.WatchForError       = false;
            info.WatchPath           = filePath;
            info.BufferKBytes        = 8;
            info.MonitorPathInterval = interval;
            info.FileFilter          = searchCriteria;
            if (info == null)
            {
                throw new Exception("WatcherInfo object cannot be null");
            }
            this.watcherInfo = info;

            Initialize();
        }
Пример #2
0
        public WatcherEx(WatcherInfo info)
        {
            if (info == null)
            {
                throw new Exception("WatcherInfo object cannot be null");
            }
            this.watcherInfo = info;

            Initialize();
        }