How to delete only files from sub folder

Hi ,

This is very simple query…
I have root folder which contains sub folders .
My requirement is to delete all the files from these sub folder without deleting Sub folder.

Ahtesham

@md.ahtesham,

Check this xaml, it will delete all the files from the subdirectory of the directory you are passing.

GetSubDirectories.xaml (7.0 KB)

@md.ahtesham

1.Use get files activity and in properties select all directory option. Install this activity from manage packages. ( Uipath.DirectorySearch.Activity)
2.Then use For each and pass your get files output.
3.Inside for each use delete file activity.

Hi @md.ahtesham,
Get all files in a string array by

String files= Directory.GetFiles(folderPath,.,SearchOption.AllDirectories)

Then use a for each in files, and use Delete activity, pass item as input.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.