DirectoryInfo.GetDirectories() is returning directories that are unaccessible, im not sure how to filter them out.

Im making a simple file explorer control…

http://ift.tt/1IPbMHs

I am having issues with DirectoryInfo.GetDirectories(), DirectoryInfo.EnumerateDirectories() and the static Directory.GetDirectories() returning directories that when enumerating their contents throw an UnauthorizedAccessException.

Ive tried making my own method to enumerate accessible directories by making sure the user has access to each directory using DirectoryInfo.GetAccessControl and GetAccessRules. But things like C:/Users/Username/Application Data/ dont get filtered out and throw an exception. My question is, how can i be sure that /Application Data/ and other system folders like it are not included?

Thanks!

by CCRed95 via /r/csharp

Leave a Reply