So i'm using Directory.GetFiles(folder, "*.jpg", SearchOption.AllDirectories)
. When i try it on the c:\
drive in windows 7, since windows 7 still had c:\documents and settings
(for legacy systems like xp), it's a protected folder. It's only protected because it's not really a folder. It's kind of a dummy folder. So when I run this code:
try
{
string[] folders = Directory.GetFiles(@"C:\\","*.jpg", SearchOption.AllDirectories);
foreach (string item in folders)
{
//blah blah
}
catch
{
}
It always throws an UnauthorizedAccessException. It doesn't let me past that. What I'm trying to do is have it skip over any folder that it doesn't have permission to access, but just continue to search, don't get caught up on the catch block, just continue. Any ideas?