Example #1
0
        public void Watch(string path, Func <string, Task> callback)
        {
            var baseDir = _fileRepo.PathOffset(path);

            _watcher = new FileSystemWatcher(baseDir);
            _watcher.IncludeSubdirectories = true;

            _watcher.Changed += _watcher_Changed;
            _watcher.Created += _watcher_Changed;

            _watcher.EnableRaisingEvents = true;

            _localLogService.LogInfo($"Monitoring {baseDir} for changes");

            _timer = new Timer(new TimerCallback(_monitorCallback), callback, 1000, 2000);
        }