System.IO.FileSystemWatcher.RunningInstance.RemoveWatchedDirectoryUnlocked C# (CSharp) Méthode

RemoveWatchedDirectoryUnlocked() private méthode

Removes the watched directory from our state, and optionally removes the inotify watch itself.
private RemoveWatchedDirectoryUnlocked ( WatchedDirectory directoryEntry, bool removeInotify ) : void
directoryEntry WatchedDirectory The directory entry to remove.
removeInotify bool true to remove the inotify watch; otherwise, false. The default is true.
Résultat void
            private void RemoveWatchedDirectoryUnlocked(WatchedDirectory directoryEntry, bool removeInotify)
            {
                // If the directory has children, recursively remove them (see comments on recursion in AddDirectoryWatch).
                if (directoryEntry.Children != null) 
                {
                    foreach (WatchedDirectory child in directoryEntry.Children) 
                    {
                        RemoveWatchedDirectoryUnlocked (child, removeInotify);
                    }
                    directoryEntry.Children = null;
                }

                // Then remove the directory itself.
                _wdToPathMap.Remove(directoryEntry.WatchDescriptor);

                // And if the caller has requested, remove the associated inotify watch.
                if (removeInotify)
                {
                    // Remove the inotify watch.  This could fail if our state has become inconsistent
                    // with the state of the world (e.g. due to lost events).  So we don't want failures
                    // to throw exceptions, but we do assert to detect coding problems during debugging.
                    int result = Interop.Sys.INotifyRemoveWatch(_inotifyHandle, directoryEntry.WatchDescriptor);
                    Debug.Assert(result >= 0);
                }
            }