Click here to Skip to main content
15,922,696 members

Comments by tonyt (Top 1 by date)

tonyt 7-Jun-10 0:38am View    
The MSDN docs make clear that using SearchOption.AllDirectories is problematic, because if an error like the one you were getting occurs, the entire call fails, rather than skipping over the unaccessable directory (which isn't limited to network volumes, it is also triggered by the 'SystemVolumeInformation' folder on local volumes, which is only accessable to the system).

IOW, you have to use a recursive or queue-based approach that processes each folder in a try/catch block, which can skip those that throw the security exception and continue processing.