For each item in array

Hi all,

I have a folder on my desktop and I would like to get the filenames listed in an excel file.
Currently I have an assign activity where variable fileList = System.IO.Directory.GetFiles(“C:\Users\XXX\Desktop\YYY)”

I defined the FileList variable as an array of strings.

I am now struggling to get them listed in an excel file.
I tried using “for each” (for each item in fileList) but then I am kind of stuck… should I use the activities “write cell/write range”? If yes what range do I have to specify if I want it to loop and enter all filenames one by one, on a new excel row?

Thanks in advance,
Kind regards

Hi @yannip,
You can use the write range. But before that

1.Use the Build data table activity with one Column name
2.Inside the for each add the row data by using of Add data row activity .
3.Finally use the write range activity to write into an excel file.


You can also use read cell.
Please find the attached (2.8 KB)

Thanks @Prashant_08 Prashant_08!! Works as expected. This was exactly what I was doing but I was not aware of how to add the counter…

@balupad14 thanks as well, I was trying but was missing something in the add data row step I think. It works with the solution above from Prashant_08.

1 Like

@Prashant_08 any idea how I can get only the filename and not the complete path?

you can do that by string manipulations

Hi @yannip,

This is the steps which i have explained you. And It will return the file name only…

Here is the source : (2.9 KB)