/// <summary> /// Creates a <see cref="FileSystemWatcher"/>. /// </summary> /// <param name="path">The path to watch.</param> /// <param name="mode">The watch mode.</param> /// <param name="filter">The file search filter to use.</param> /// <returns>The created <see cref="FileSystemWatcher"/>.</returns> private BlueCollar.FileSystemWatcher CreateWatcher(string path, FileSystemWatcherMode mode, string filter) { BlueCollar.FileSystemWatcher watcher = null; try { watcher = new BlueCollar.FileSystemWatcher(path); watcher.Operation += new FileSystemEventHandler(this.WatcherOperation); watcher.Mode = mode; watcher.Filter = filter; watcher.Threshold = this.Threshold; watcher.EnableRaisingEvents = true; } catch { if (watcher != null) { watcher.Dispose(); } throw; } return(watcher); }
/// <summary> /// Destroys the <see cref="Diagnostics.FileSystemWatcher"/>. /// </summary> private void DestroyWatcher() { if (this.watcher != null) { this.watcher.Dispose(); this.watcher = null; } }
/// <summary> /// Creates the <see cref="Diagnostics.FileSystemWatcher"/> to watch for configuration changes. /// </summary> private void CreateWatcher() { this.DestroyWatcher(); this.watcher = new BlueCollar.FileSystemWatcher(Path.GetDirectoryName(BlueCollarServiceSection.Section.ElementInformation.Source), Path.GetFileName(BlueCollarServiceSection.Section.ElementInformation.Source)); this.watcher.Operation += new FileSystemEventHandler(this.WatcherOperation); this.watcher.Mode = FileSystemWatcherMode.IndividualFiles; this.watcher.Threshold = 1000; this.watcher.EnableRaisingEvents = true; }
/// <summary> /// Creates a <see cref="FileSystemWatcher"/>. /// </summary> /// <param name="path">The path to watch.</param> /// <param name="mode">The watch mode.</param> /// <param name="filter">The file search filter to use.</param> /// <returns>The created <see cref="FileSystemWatcher"/>.</returns> private BlueCollar.FileSystemWatcher CreateWatcher(string path, FileSystemWatcherMode mode, string filter) { BlueCollar.FileSystemWatcher watcher = null; try { watcher = new BlueCollar.FileSystemWatcher(path); watcher.Operation += new FileSystemEventHandler(this.WatcherOperation); watcher.Mode = mode; watcher.Filter = filter; watcher.Threshold = this.Threshold; watcher.EnableRaisingEvents = true; } catch { if (watcher != null) { watcher.Dispose(); } throw; } return watcher; }