There is some inconsistency there. The kernel32.dll FindFirstFileEx method doesn't support multiple filters, so the pipe separated filters was only added to GetFiles but not to EnumerateFiles.
The issue with multiple filters is the possibility that the same file is hit by multiple filters. E.g. if there is a file called data.txt and two filters are specified data.*|*.txt then the EnumerateFiles would return data.txt twice. However, the GetFiles(...) method checks for duplicates.
EnumerateFiles should probably support pipe separated filters, but come with a warning in the method description that the same file could be returned multiple times if the filename is matched by more than one search filter.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there
do you have a way to use multiple search patterns ie (.txt|.jpg|*.dat)
thanks!
Eric
GetFiles(String path, String searchPattern = "*", ...);
/// <param name="searchPattern">The search string to match against files in the path. Multiple can be specified separated by the pipe character.
Thank you! This worked
out of curiosity, why doesn't the enumeratefiles function support this also?
thanks
Eric
There is some inconsistency there. The kernel32.dll FindFirstFileEx method doesn't support multiple filters, so the pipe separated filters was only added to
GetFiles
but not toEnumerateFiles
.The issue with multiple filters is the possibility that the same file is hit by multiple filters. E.g. if there is a file called
data.txt
and two filters are specifieddata.*|*.txt
then theEnumerateFiles
would return data.txt twice. However, theGetFiles(...)
method checks for duplicates.EnumerateFiles
should probably support pipe separated filters, but come with a warning in the method description that the same file could be returned multiple times if the filename is matched by more than one search filter.