How to check if there are any files in a folder uipath

Hello, how to check if there are any files in a folder UiPath? I have in if activity, condition: Directory.GetFiles(C:\Users\login\Desktop\Folder\Folder\Folder, β€œ.”, SearchOption.AllDirectories).Count > 0, but I have error:
image
Any ideas what could be the problem?
Thank You :slight_smile:

Hi,

Can you try the following?

Directory.GetFiles("C:\Users\login\Desktop\Folder\Folder\Folder", "*", SearchOption.AllDirectories).Count > 0

Regards,

2 Likes

Thank You @Yoichi :slight_smile: It works! Do you know how to make it check files in two folders at the same time?

Basically, we need to check the folder one by one. However we can write it using a single expression as the following, for example.

arrFolder = {β€œc:\temp”,β€œc:\test”}

Then, condition will be as the following.

arrFolder.Sum(Function(f) Directory.GetFiles(f,"*").Count)>0

image

Regards,

2 Likes

Thank You! Have a nice day :slight_smile:

1 Like

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