void StartLocalFileSystemWatcher() { Trace.TraceInformation("Initializing local file watcher..."); _LocalFileSystemWatcher = new LocalFileSystemWatcher(SreConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryPull, SreConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryArchive); Watchers.FileSystemWatcherEventHandler handler = new Watchers.FileSystemWatcherEventHandler(FileDownloaded); _LocalFileSystemWatcher.FileDownloaded -= handler; _LocalFileSystemWatcher.FileDownloaded += handler; _LocalFileSystemWatcher.Run(); Trace.TraceInformation("Local file watcher initialized with Pull = '{0}' and Archive = '{1}'.", SreConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryPull, SreConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryArchive); }
public LocalEvents(WebShellFolderServer server, int synchronizePeriod = 60000) { if (server == null) { throw new ArgumentNullException(nameof(server)); } Server = server; SynchronizePeriod = synchronizePeriod; _watcher = new LocalFileSystemWatcher(WebApi.LocalDirectory.FullName); _watcher.Event += OnWatcherEvent; _watcher.Start(); _synchronizeTimer = new Timer(SynchronizeCallback); _synchronizeTimer.Change(SynchronizePeriod, Timeout.Infinite); }