I need to go through various directories on the computer (via DirectoryInfo). Some of them aren’t accessible, and UnauthorizedAccessException occurs. How can I check directory access without catching the exception?
I need to go through various directories on the computer (via DirectoryInfo). Some of
Share
You need to use the
Securitynamespace.See this SO answer.
From the answers:
Update: (following comments)
FileIOPermissiondeals with security policies not filesystem permissions, so you need to useDirectoryInfo.GetAccessControl.