In this post, we will get all the files present in a folder and delete them one by one. First, we will store the files in an array of strings and then we iterate through the array.
Prerequisites
Add a new Assign
activity. Create a new variable by pressing Cntrl+K
. Name the variable listOfFiles
. Give the value of the variable as below –
Directory.GetFiles("<Your Folder Path>")
You will notice an error because we need to change the variable type to System.String[]
. Open the variables panel and change the type.

Add a For Each
activity and iterate through the list of files and delete them one by one using the Delete
activity. You will have to change the item/file to a string in order to delete it.
The Delete
activity takes one argument, i.e., the Path of the file which we are already getting by iterating through all the files in a folder.

Your complete flow looks like this.

Run the process and confirm the file delete.


Thank you All!!! Hope you find this useful.
If you liked our content and it was helpful, you can buy us a coffee or a pizza. Thank you so much.

Leave a Reply