public bool HasAccessToDirectory(string directory) { if (_directoryAccessDictionary.ContainsKey(directory)) { return(_directoryAccessDictionary[directory]); } string volume = GeneralConverters.GetVolumeLabelFromPath(directory); var drives = DriveInfo.GetDrives().ToList(); if (drives.Any(d => d.IsReady && d.Name.Equals(volume, StringComparison.CurrentCultureIgnoreCase))) { try { var directoryInfo = new DirectoryInfo(directory); directoryInfo.EnumerateFiles(); _directoryAccessDictionary.Add(directory, true); return(true); } catch (Exception) { // ignored } } _directoryAccessDictionary.Add(directory, false); return(false); }