Now I am about to get directories of "C:\Documents and Settings" like this:
var d=Directory.GetDirectories(@"C:\Documents and Settings")
Visual Studio reports an error:
System.UnauthorizedAccessException: 'Access to the path 'C:\Documents and Settings' is denied.'
Well, the directory is inaccessible.
I want to get to know whether the directory about to get is accessible.
Many tutorials, just like this:https://stackoverflow.com/questions/172544/ignore-folders-files-when-directory-getfiles-is-denied-access
, are using a try&catch to avoid the error.
As we know, try&catch will slow down the speed. And also, I don't think it is the best way.
Is there any way to solve this? Thank you.