According to the Microsoft Docs site for Directory.EnumerateFiles, the search pattern parameter will match any extension beginning with the specified pattern when it is exactly 3 characters. However, this is not working on file shares, only local drives.
For a directory of \\share\folder\ containing a single file named file.xlsx, this first code snippet does not return it:
public static List<string> GetAllFilesFromDirectory(string directory) =>
new[] { "*.csv", "*.xls", "*.txt" }.SelectMany(ext => Directory.EnumerateFiles(directory, ext)).ToList();
However, if I add the *.xlsx pattern, it does return it:
public static List<string> GetAllFilesFromDirectory(string directory) =>
new[] { "*.csv", "*.xls", "*.xlsx", "*.txt" }.SelectMany(ext => Directory.EnumerateFiles(directory, ext)).ToList();
I also tested this with the same file in the C:\temp directory and it found returned it both ways.
This is running in a .NET Framework 4.7.2 console app.
Am I missing something in the search pattern? Or does this not work with file shares the same way as local drives? Would this be expected?