public virtual FileSystemWatcher GetWatcher(string uniquePath)
        {
            string folderPath = _fileSystem.GetFolderPath(uniquePath);

            if (folderPath == null)
            {
                return(null);
            }

            string uniqueFolder = _fileSystem.UniqueFolder(folderPath);

            if (_watcherByFolder.TryGetValue(uniqueFolder, out FileSystemWatcher watcher))
            {
                return(watcher);
            }

            if (!_fileSystem.FolderExists(uniqueFolder))
            {
                return(null);
            }

            _watcherByFolder[uniqueFolder] = watcher = new FileSystemWatcher(uniqueFolder)
            {
                NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.DirectoryName
            };

            watcher.FullyReleased += OnWatcherFullyReleased;

            return(watcher);
        }
        public virtual FileSystemWatcher GetWatcher(string path)
        {
            // We use a watcher by path root because watching a specific folder will lock all its parent folder with Windows.
            // It probably have an impact on performance but locking folders can have an impact on user experience.

            string pathRoot = _fileSystem.UniqueFolder(Path.GetPathRoot(path));

            if (_watcherByRoot.TryGetValue(pathRoot, out FileSystemWatcher driveWatcher))
            {
                return(driveWatcher);
            }

            _watcherByRoot[pathRoot] = driveWatcher = new FileSystemWatcher(pathRoot)
            {
                NotifyFilter          = NotifyFilters.FileName | NotifyFilters.LastWrite | NotifyFilters.DirectoryName,
                IncludeSubdirectories = true
            };

            driveWatcher.FullyReleased += OnWatcherFullyReleased;

            return(driveWatcher);
        }