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.
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
Comments
Post a Comment