Get all the Sub-Folders and save it to Excel

I wanted to do an automation where I want to get the names of all the sub-folder and save it in a excel or list. Can someone help me with this? I am new to UIPath

Hi @Author_Community ,

Is this what you were looking for?

image

Directory.GetDirectories(str_folderPath,"*.*",SearchOption.AllDirectories).OrderBy(Function(o) o.ToString).ToList()

You can then use a For Each Activity to Loop through each item in the List and assign it to your DataTable either by overwriting it or by adding a new DataRow.
image

image

DirectoryGrabbinSequence.xaml (8.6 KB)

Kind Regards,
Ashwin A.K

This looks good, but there is an issue for execution, it throws an error.

Hi @Author_Community ,

Could you please share the screenshot of the error?

Kind Regards,
Ashwin A.K

This is what has been done, please correct if wrong anywhere

Hi @Author_Community ,

Could you verify whether the TypeArgument for the For Each is String?

image

Kind Regards,
Ashwin A.K

Yes the Type is String. You can look down below in the attached image

You could try adding a ToString after the Split operation - attach it to the Last().

Also, could you verify whether you have passed in the array into the ArrayRow and not the DataRow field?

I am assuming that you are using the sequence I shared?

image

Kind Regards,
Ashwin A.K

I am using the StudioX platform, can that answer be shared as an equivalen to StudioX. As in it I see the Add Data Row or Add List as a Row in the options of Add Data Rows

Hi @Author_Community ,

Not a problem, one last thing, could you try passing in the array to the third field in the Add Data Row Activity and let me know if that works?

Meanwhile I’ll figure something out in StudioX.

Kind Regards,
Ashwin A.K

Shows me this error

Another error means we are making progress!

Now, when you building the DataTable, you have to define two columns since we are adding two items into it.
I’m not sure exactly how we can add that, my UiPath is taking a while to switch over to StudioX, give me some time.

Kind Regards,
Ashwin A.K

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