Skip to content

Instantly share code, notes, and snippets.

@lcaballero
Created March 5, 2013 10:00
Show Gist options
  • Save lcaballero/5089204 to your computer and use it in GitHub Desktop.
Save lcaballero/5089204 to your computer and use it in GitHub Desktop.
Recursive Linq Traversing a Tree. This version traverses a directory structure.
public static IEnumerable<string> Files(
this string root, Func<string, bool> accept)
{
return
Directory.GetFiles(root).Where(accept)
.Concat(
Directory.GetDirectories(root)
.SelectMany(d => d.Files(accept)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment