How can I add different validation of a document extension, if I´m using GetFiles?

I try to use: directory.getfiles(config(“DownloadFolder”).toString, “.xsl|.xlsx|*.pdf”)
But it doesn´t work, it says that there are Illegal characters in path.
Is another simply way to do it?

Hello @dulce.santacruz
try this


Otherwise you can use For each file in folder activity

1 Like

Hi @dulce.santacruz
Try this
Directory.GetFiles(path, “.”, SearchOption.AllDirectories).Where(Function(s) s.EndsWith(“.mp3”) Or s.EndsWith(“.jpg”))

1 Like

If it says illegal characters in the path, what value is in config(“DownloadFolder”)?

It´s the name of the folder where my documents take place before download it :smiley: I check it individually and what makes the error are the: *pdf…


arrFullFilePaths | String() - String Array =

(From f in Directory.GetFiles(MyDirPathVar)
Let xt = Path.GetExtension(f).toUpper.Replace(".","")
Where {"PDF","TXT","XML"}.Contains(xt)
Select fp = f).toArray

Taken from:

Here’s another way to achieve that :smile:
Directory.GetFiles(“C:\path”, “.”, SearchOption.AllDirectories)
.Where(file => new string { “.jpg”, “.gif”, “.png” }

Let me know if that works :slight_smile:

Thanks! I tried with the other answer that you send me, and I can´t make it work, let my try this, thanks!!

What means the square before string?

1 Like

Here :slight_smile: (61.9 KB)

Hi @dulce.santacruz

How about this expression


SearchOption.AllDirectories - Used for searching all the directories in the mentioned folder path


Check out the tutorial


1 Like

The square is the array symbol, it does not display very well in the comments.
Here are the two ways to do it: :smile: (34.1 KB) (61.9 KB)

Let me know if it works

Yes, it works!

1 Like

Please as text because this file is not open in my old uipath

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