Need assistance with deleting files from a specific folder using UiPath

Hello UiPath Community,

I’m relatively new to UiPath and I’m trying to create an automation workflow to delete all files from a specific folder. I’ve followed the steps outlined in the UiPath documentation and other resources, but I’m encountering an issue with the “Delete File” activity.

Here’s a summary of what I’ve done so far:

  1. I’ve used an “Assign” activity to assign the folder path to a variable (folderPath).
  2. I’ve used a “For Each” activity to iterate through each file in the folder.
  3. Inside the “For Each” loop, I’ve used another “Assign” activity to assign the list of files in the folder to a variable (filesList) using the expression Directory.GetFiles(folderPath).
  4. I’m attempting to use the “Delete File” activity inside the “For Each” loop to delete each file, using the file variable as the file path.

However, I’m encountering the following error message: “Value cannot be null. (Parameter ‘path’)”.

Could you please assist me in troubleshooting this issue? Is there a better approach to achieve my goal of deleting all files from a specific folder using UiPath?

Thank you in advance for your help!

Hi @Or_Levi,

For that use case, you can use the ‘For Each File in Folder’ activity and not the standard ‘For Each’, then use the ‘Delete File’ activity inside the loop and set the path as CurrentFile.FullName.

Juan P.

2 Likes

Hey @juan.porras1
I tried your suggestion, and it worked perfectly!
thank you so much for your help!

Hi @Or_Levi,

Happy to know that. If the solution was helpful, don’t forget to mark my reply as Solution so others can find it.

Happy automation!

Juan P.

1 Like

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