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
filtered_Files(File).ToString<>""

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

Sorry if i misunderstood your issue.

Thanks,
Salini

1 Like

Hi @NHoe ,

You could try to add within your code a condition to check if your file exists. Refer to https://docs.microsoft.com/en-us/dotnet/api/system.io.file.exists?view=net-6.0

or

You could use the UiPath in order to check if your file exists. This activity might help you here: https://docs.uipath.com/activities/docs/file-exists-x

Hope I didn’t misunderstand the issue
Best regards,
Marius

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