how to delete all subfolder and all files from given path

i want that without deleting given path directory delete all subfolder and files from given path.

Hope you know the “recursive function” logic, same needs to be applied. In place of function it will be a workflow.

is there not straight forward way given path delete all directory and file. i want simple way.

I dont think so…but writing a recursive workflow is not that difficult.

Hey @pankajs3,

Please use the code below:

Place this code inside the assign activity:
subDir=Directory.getDirectories(“Path Of the Root Directory”)

//subDir should be an array of string//

use foreach loop to iterate through this string array and place the delete activity inside the loop.

Delete activity should have element from the array in the path property.

for ex:

foreach(var r in sunDir)
{
then r should go in place of path in delete activity.
}

Hi @pankajs3

Please check out Delete activity. It will delete the folder, sub-folders and files of a given path.

Hello! In case you need more alternatives than the ones already provided, you can also take a look on Go! and get some reusable components from there for this task (there are quite a few for this specific function!):
https://go.uipath.com/components?sort=most_relevant&search=delete&=&sort=most_relevant

1 Like

Hi @pankajs3,

Instead of going for some workflow, the simplest way to delete all subfolders and files from given path is to use Long Path Tool software. I think it’s the simplest way to do this.

Have you tried ‘Long Path Tool’ ?
it’s very useful in this type of case.