Skip to content

Instantly share code, notes, and snippets.

@JeremyKuhne
Created March 8, 2018 23:58
Show Gist options
  • Save JeremyKuhne/3d8850d9d5795463437b81b94cfa1dd8 to your computer and use it in GitHub Desktop.
Save JeremyKuhne/3d8850d9d5795463437b81b94cfa1dd8 to your computer and use it in GitHub Desktop.
Counting files example
public static int CountFiles(string directory, bool recursive)
{
return (new FileSystemEnumerable<int>(
directory,
(ref FileSystemEntry entry) => 1,
new EnumerationOptions() { RecurseSubdirectories = recursive })
{
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory
}).Count();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment