Using OR clause in Directory.GetFiles

Hi, I have a for each activity that is running through a folder location.

I currently have Directory.GetFiles(“Data\Unzip”,“*.csv”) to select all csv files, but I’d also like to return a file if it ends with .txt.

What syntax would I use there to include .csv or .txt ?

Thanks!

Hi,

How about the following expression?

Directory.GetFiles("Data\Unzip").Where(Function(f) {".csv",".txt"}.Contains(Path.GetExtension(f).ToLower)).ToArray

Regards,

Nice one, that works! Thanks!

1 Like

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