title: Is there a way of recover from an Exception in Directory.EnumerateFiles?
body: <p>In .NET 4, there's this <a href="http://msdn.microsoft.com/en-us/library/dd383571%28v=VS.100%29.aspx" rel="noreferrer">Directory.EnumerateFiles()</a> method with recursion that seems handy.<br>
  However, if an Exception occurs within a recursion, how can I continue/recover from that and continuing enumerate the rest of the files?</p>
  
  <pre><code>try
  {
    var files = from file in Directory.EnumerateFiles("c:\\",
                             "*.*", SearchOption.AllDirectories)
                select new
                {
                  File = file
                };
  
    Console.WriteLine(files.Count().ToString());
  
  }
  catch (UnauthorizedAccessException uEx)
  {
    Console.WriteLine(uEx.Message);
  }
  catch (PathTooLongException ptlEx)
  {
    Console.WriteLine(ptlEx.Message);
  }
  </code></pre>