Enumerating Directories and Files on a Drive is a problem: as you may have found out, even a simple call to GetDirectories on your root drive may crash with one of several exceptions: UnauthorizedAccessException, PathTooLongException, IOException.
.NET 5 (Core) adds a new EnumerationOptions facility that will skip over errors: IgnoreInaccessible [
^].
One solution for pre 5 .NET is to use the class published on StackOverflow in 2015 by Matthew Brubaker, and, then maintained, updated, on GitHub by Brian Hart: [
^].
I am not using 5.0.