How To Delete Multiple Files – In UiPath

While automating business processes, we deal with a lot of files and might perform few activities on them like deleting, moving or renaming.

Here, for now, let’s see how to delete multiple files from a folder!!!

Array.ForEach(Directory.GetFiles(our_DirectoryPath),Sub(x) File.Delete(x))

Note:
Replace our_DirectoryPath with your desired folder path

Example

Implementation using UiPath :

Let us implement a project to delete multiple files from a given folder 🙂

Step 1:
Drag “Assign” activity into the designer panel and supply the “Folder Path” to it.

UiPath Delete Multiple files from a folder 1.png

Step 2:
Drag “If” activity to check if the folder contains any files.

Directory.GetFiles(DirectoryPath).Count > 0

UiPath Delete Multiple files from a folder 2.PNG

Step 3:
Drag “Invoke Code” activity, supply the below-mentioned code to it to and pass the folder’s Path from which we have to delete the files.

Array.ForEach(Directory.GetFiles(DirectoryPath),Sub(x) File.Delete(x))

UiPath Delete Multiple files from a folder 3UiPath Delete Multiple files from a folder 4

Step 4:
Now, execute the workflow to find the result 🙂

Click here to download the Source Code…

Hope it has helped you…

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: