VisualBasicValue<Boolean>: Index was outside the bounds of the array

Hello all,

I have created a for each loop in a FlowChart for different files, this works so far.

My problem is that the target folder can also be without these files that the bot should read in, how can I check this?

Multiple Assign:

File = 0
File_Path = Directory.GetFiles(“C:”, “Test_"+".xlsx”)
filtered_Files = File_Path.Where(Function (x) File_Path.Any(Function (f) x.Contains(f))).toArray
FileName_exact = filtered_Files(File).ToString

Once the folder is empty, FileName_exact = filtered_Files(File).ToString is marked as an error.

I have tried the following in a flow dcision, but this does not work either

Hello @NHoe , Please try to check the count of an array as below:
if zero the array did not return any files

Sorry if i misunderstood your issue.


1 Like

Hi @NHoe ,

You could try to add within your code a condition to check if your file exists. Refer to


You could use the UiPath in order to check if your file exists. This activity might help you here:

Hope I didn’t misunderstand the issue
Best regards,

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