Delete files with extension .xls


I need to loop throught files in folder and delete all with .xls extension.

I have for each loop. For each file in string.

How to write such thing?

How about this?


Hi @logan.capp ,

Please see example…

ok, how should I fill Delete activity? how to get the path of file I’m currently in loop?

you can assign a array(Of String) variable with the files that ends with xls extension
using Directory.GetFiles(folderPath, “*.xls”)

and loop through the array with for each and use File>Delete activity to delete the file.

Hi @logan.capp ,

Filled Delete with item. Replace default value of variable MyFolder from “D:\MyFolder” to your file path.

ok, but how to get it? Path witll be path of folder+""+filename. I dont know how to get this filename.

Hi @logan.capp

You only need to provide the file path. Directory.EnumerateFiles( path , search pattern ) will return all the files. It is a standard library from Microsoft, click here for details.

Hi Logan, I think you are referring this below.

And the delete activity screenshot is below.


Hi, yes I’m. I have same flow with I have problem with file variable that You have in Delete activity.

File is a type and cannot be used as a expression… That is was is written :frowning:

@logan.capp - Please watch this video…You can easily do by yourself.

Delete specific files starts at 8:15

1 Like

thanks for video, but that is exactly what I do.

Should I declare file somewhere maybe?

@logan.capp - Please find the starter help here (56.4 KB)


I had a mistake and delete not in a loop… Thanks

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