public void WatchFile(string filePath) { bool flag = false; string str = PathHelper.GetDirectory(filePath); if (!FileChangeWatcher.DirectoryIsAccessible(str)) { flag = true; str = FileChangeWatcher.GetExistingParentDirectory(str); } if (string.IsNullOrEmpty(str)) { return; } FileChangeWatcher.WatchedDirectory watchedDirectory; lock (this.syncLock) { if (!this.pathToWatchedDirectories.TryGetValue(str, out watchedDirectory)) { watchedDirectory = new FileChangeWatcher.WatchedDirectory(this, str); this.pathToWatchedDirectories.Add(str, watchedDirectory); } } if (flag) { watchedDirectory.IncludeSubdirectories = flag; } watchedDirectory.WatchFile(filePath); }
private void MoveToParentDirectory(FileChangeWatcher.WatchedDirectory watchedDirectory) { this.pathToWatchedDirectories.Remove(watchedDirectory.Path); string existingParentDirectory = FileChangeWatcher.GetExistingParentDirectory(watchedDirectory.Path); if (string.IsNullOrEmpty(existingParentDirectory)) { return; } string[] strArray = Enumerable.ToArray <string>(watchedDirectory.FilePaths); if (!this.pathToWatchedDirectories.TryGetValue(existingParentDirectory, out watchedDirectory)) { watchedDirectory = new FileChangeWatcher.WatchedDirectory(this, existingParentDirectory); this.pathToWatchedDirectories.Add(existingParentDirectory, watchedDirectory); } watchedDirectory.IncludeSubdirectories = true; foreach (string filePath in strArray) { watchedDirectory.WatchFile(filePath); } }