I try to use the recursive built in method:
public IEnumerable<string> Foo(string path)
{
try
{
foreach (string file in Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories))
{
yield return file;
}
}
catch (Exception)
{ }
}
And received this error:
Cannot yield a value in the body of a try block with a catch clause
How can I use the try-catch
in order to avoid me method to crash is I don't have folder permission ?