Is there a way of recover from an Exception in Directory.EnumerateFiles?

前端 未结 4 1191
攒了一身酷
攒了一身酷 2020-12-19 12:16

In .NET 4, there\'s this Directory.EnumerateFiles() method with recursion that seems handy.
However, if an Exception occurs within a recursion, how can I continue/recove

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 12:32

    I think that this approach does not work correctly. Although the UnauthorizedAccessException is caught, the iteration immediately stops when it occurs. So you just get all files that were retrieved before the exception was thrown.

提交回复
热议问题