I found this code that gets an array of files out of a DirectoryInfo
:
FileInfo[] fileInfoArray = di.EnumerateFiles().Where(f => extensions.Contains(f.Extension.ToLower())).ToArray();
But it only searches the direct children of the path of DirectoryInfo
. i.e., it does not include grandchildren.
I guess I need to add SearchOption.AllDirectories
parameter to somewhere, but where?
I tried :
di.EnumerateFiles(SearchOption.AllDirectories).Where(f => extensions.Contains(f.Extension.ToLower())).ToArray();
But it yields an error.
So how do I search with a pattern, including all subdirectories ?
Thanks for any help !