In my application I use the following command to get all files from a selected path:
foreach (string currentFile in Directory.EnumerateFiles(@"c:\", "*.*", SearchOption.AllDirectories))
{
//some logic here
}
The thing is that when trying to access certain directories such as c:\Documents and Settings
I get an UnauthorizedAccessException
.
The folder mentioned above doesn't show in Windows Explorer
or in the .NET System.Windows.Forms.FolderBrowserDialog
and i can't find a specific attribute of this folder so I could filter the enumeration by.
I tried this and this but with no use.
Is there any kind of attribute or parameter I can use to restrict this kind of directories from my loop?