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.

Step 2:
Drag “If” activity to check if the folder contains any files.
Directory.GetFiles(DirectoryPath).Count > 0

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))


Step 4:
Now, execute the workflow to find the result 🙂
Click here to download the Source Code…
Hope it has helped you…
Like this:
Like Loading...
Related
Published by Sharath Raju
I am an engineer by profession and by heart :)
It's been 7+ years since I have been working with software development and robotic process automation.
I have implemented close to 80+ RPA processes in total by using Uipath.
It is so true that someone learns more by not reading something but by practicing the skill.
I have been trying to understand exactly where people who are just starting out their career struggle and understand the pain of struggling for hours trying to figure something out.I can help you with that.
Having a passion to share my piece of content, I have created step-by-step easy-to-digest courses.
My goal is to help you get ready for the future by learning new talents and becoming more productive by providing you with relevant and useful courses.
I'm still learning and exploring my field of work :)
Every feedback should be as valuable as you are to me, please feel free to reach out to me if you have any feedback, questions, or need any help.Thank You...
View all posts by Sharath Raju