public SystemWatchfolder(string path, string watchFilter, bool readInitialFiles, ISystemFileRouter router)
        {
            _path             = path;
            _filter           = watchFilter;
            _readInitialFiles = readInitialFiles;
            _router           = router;

            _watchers = new List <FileSystemWatcher>();

            foreach (var f in _filter.Split('|'))
            {
                var watcher = new FileSystemWatcher
                {
                    Path         = _path,
                    NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                    Filter       = f
                };
                // Add event handlers.
                watcher.Changed += OnChanged;
                watcher.Created += OnChanged;
                // Ignore deletions
                //watcher.Deleted += OnChanged;
                watcher.Renamed += OnRenamed;

                _watchers.Add(watcher);
            }
        }
Пример #2
0
        public SystemWatchfolder(string path, string watchFilter, bool readInitialFiles, ISystemFileRouter router)
        {
            _path = path;
            _filter = watchFilter;
            _readInitialFiles = readInitialFiles;
            _router = router;

            _watchers = new List<FileSystemWatcher>();

            foreach (var f in _filter.Split('|'))
            {
                var watcher = new FileSystemWatcher
                {
                    Path = _path,
                    NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName,
                    Filter = f
                };
                // Add event handlers.
                watcher.Changed += OnChanged;
                watcher.Created += OnChanged;
                // Ignore deletions
                //watcher.Deleted += OnChanged;
                watcher.Renamed += OnRenamed;

                _watchers.Add(watcher);
            }
        }