Skip to content

Instantly share code, notes, and snippets.

@JeremyKuhne
Created March 9, 2018 00:05
Show Gist options
  • Save JeremyKuhne/bc06fc15a2911796cc823150c257db29 to your computer and use it in GitHub Desktop.
Save JeremyKuhne/bc06fc15a2911796cc823150c257db29 to your computer and use it in GitHub Desktop.
Counting file bytes example
public static long CountFileBytes(string directory, bool recursive)
{
return (new FileSystemEnumerable<long>(
directory,
(ref FileSystemEntry entry) => entry.Length,
new EnumerationOptions() { RecurseSubdirectories = recursive })
{
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory
}).Sum();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment