Unfortunately, this is one of the rare cases where you need to make a fine-grain try-catch block and block the propagation if exception (but not re-throwing). In this approach, you need to put your try-catch in the minimal context containing the line with the operation with each file system element. This way, the search will continue. I'll lean the problem of writing code for your home exercise, this is very simple.
But also, you can try recursive
GetFiles
, the difference one:
http://msdn.microsoft.com/en-us/library/ms143316.aspx[
^];
using
System.SearchOption.AllDirectories
:
http://msdn.microsoft.com/en-us/library/ms143448.aspx[
^].
[EDIT]
If you really want to access all files, and make most of them accessible, you would also need to access elevated privileges in the manifest. The user would need to have admin access and confirm the request.
—SA