How to filter directory to list only files with name e.g. "cmeyer" (string manipulation)

I am trying to filter a dircetory with
Directory.GetFiles(“S:\DACH\Winsped\PROD\DATEN\EXCEL”,“cmeyer”) but it wont work any suggestions?

Hi,

Can you try the following expression?

files = System.IO.Directory.GetFiles("S:\DACH\Winsped\PROD\DATEN\EXCEL").Where(Function(f) System.IO.Path.GetFileNameWithoutExtension(f).Contains("cmeyer")).ToArray()

Regards,

1 Like

As an alternate try this…

 Directory.GetFiles("S:\DACH\Winsped\PROD\DATEN\EXCEL","*cmeyer*")

Tried that too but didnt work. Yoichi’s solution worked.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.