I have problem searching folder and find all files with specific name. With this method I am able to browse my folder and find all files. But only Word files.
Dim fi As FileInfo() = path.GetFiles(fileName & "*.doc*", SearchOption.AllDirectories)
Now I would like to search Word and PDF. Is there a way how I can find it? If I just write a dot instead of .doc it searches the folder but finds all files. Excel, txt etc.
Dim fi As FileInfo() = path.GetFiles(fileName & "*.*", SearchOption.AllDirectories)
The goal would be to find only certain types of files.
It is not possible to use the GetFiles method to enumerate files with multiple extensions. To do that, you'll have to write your own code to do the filtering. I also recommend you use the
EnumerateFilesmethod as it provides better performance over theGetFilesmethod in most cases.Here is sample code to do the filtering as you require