Created
March 8, 2018 23:58
-
-
Save JeremyKuhne/3d8850d9d5795463437b81b94cfa1dd8 to your computer and use it in GitHub Desktop.
Counting files example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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