How to get the nth file in a directory

Hello, I was wondering how you would tell UiPath to get the nth file (for example, the 5th file) in a directory. This is something I need for the automation I am working on currently.

Yah it can be done like this
–use a assign activity like this
arr_files = Directory.GetFiles(“yourfolderpath”)
where arr_files is a variable of type array of string
–now use a writeline activity (for now, later we can mention this in any activity where it takes in filepath as input)
and mention like this
arr_files(4).ToString //which will print the 5 thr file path
as it starts from 0 for first element in array

Cheers @Hisuhong

2 Likes

Thank you so much! :smiley:

1 Like

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