Get files with multiple extensions

I want to read multiple extension files from a directory.
How to do that in UIPath?
Thank you.

You can use the following expression to filter the multiple extension files from a given directory.

files = Directory.GetFiles("C:\path", "*.*", SearchOption.AllDirectories).Where(Function(s) s.EndsWith(".mp3") Or s.EndsWith(".jpg"))

Karthik Byggari


Thank you. Exactly what I am looking for.

1 Like

The expression be like this
arr_files = Directory.GetFiles(“yourfolderpath”)

This will take all kind of files from the folder
Where arr_files is a variable of type array of string

Cheers @Ulrich_Hoch

1 Like

Hi @Palaniyappan
That expression will get all the files from a folder. But my requirement is different. I need only set of extension files.
Thanks for your reply.

Hi @Ulrich_Hoch,

Try with the below code.

 Directory.GetFiles("C:\path", "*.*", SearchOption.AllDirectories)
      .Where(file => new string[] { ".jpg", ".gif", ".png" }

Just replace the where with all the extensions you want to search for.


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