List all files in a folder and its subfolders with linq
How to list all files in a folder and all its subfolders into a single LINQ request?
C#
private static IEnumerable<string> GetFiles(string path)
{
return Directory.EnumerateFiles(path)
.Concat(Directory.EnumerateDirectories(path).SelectMany(GetFiles));
}
Do you have a question or a suggestion about this post? Contact me!
Enjoy this blog?💖 Sponsor on GitHub