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

Directory.GetFiles(Yourpath","*.*",SearchOption.AllDirectories)

Otherwise you can use For each file in folder activity
image

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…

e.g.

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:

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

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:
BusinessException.zip (61.9 KB)

Hi @dulce.santacruz

How about this expression

Directory.GetFiles(Environment.CurrentDirectory+"\WordPdf\","*.*",SearchOption.AllDirectories)

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

image

Check out the tutorial

Regards
Gokul

1 Like

@dulce.santacruz
The square is the array symbol, it does not display very well in the comments.
Here are the two ways to do it: :smile:

myProcess.zip (34.1 KB)
BusinessException.zip (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.