Use OS-level filtering for searchPattern in DirectoryInfo.GetFiles, and add search pattern property/parameter to FileSystemEnumerable #127501
Unanswered
benstevens48
asked this question in
Ideas
Replies: 2 comments
-
|
This seems to have been implemented already in #122947 and #123695 . |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Interesting, I was browsing the source from the docs so didn't see that. But I don't think the search pattern constructor for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
As far as I can tell,
DirectoryInfo.GetFilesand related functions apply the file name search pattern filtering in managed code. However, there is support, at least on Windows, for it at the OS level. Indeed,FileSystemEnumerable/FileSystemEnumeratoruses NtQueryDirectoryFile which accepts a file name search pattern, but this is parameter is not used. Surely it would be a lot quicker to use this OS-level parameter for searching e.g. filtering by a single file extension? I suggest adding asearchPatternstring to the constructor ofFileSystemEnumerable/FileSystemEnumerator(or a property etc, whichever seems best), which can be passed to the OS-level function. If not supported on other OSes then it can just use filtering in managed code as currently. ThenDirectoryInfo.GetFilesetc can also use this newsearchPatternparameter internally (I believe they useFileSystemEnumerable/FileSystemEnumeratorinternally).Beta Was this translation helpful? Give feedback.
All reactions