try
{
string[] files = Directory.GetFiles("C:\MyDir", "*.*", SearchOption.AllDirectories);
}
catch (UnauthorizedAccessException)
{
}
catch (Exception ex)
{
}
GetFileSystemEntries
will also throw the
UnauthorizedAccessException
, so I don't think you'll gain anything by using it instead. I also don't know the condition of the array of files - does it continue on with the operation or stop at the exception? I'd have to try running some code, but then again, you can do that yourself.