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

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.

I would do this from the Command Promt using this:

In my case we had to clean up the user AppData folders after each Robot execution.
Feeding this into Input command:
del "%appdata%\..\locallow" /S /F /Q >nul 2>&1

Main.xaml (4.9 KB)

try thisDeleteSubFolder.xaml (21.7 KB)

1 Like

Thanks Buddy.It helps