How to delete all files that contain xlsx in their names?

Hi,

I would like to delete all files in a folder that contain “xlsx” in their names.

What would be the best way to go about that?

Thanks

@Kamalen_Reddy Do you want to delete xlsx file types only or the file names which contain xlsx ?

@Kamalen_Reddy
The Directory.getfiles Method has a filter argument available. So for xlsx Extension give a try on *.xlsx. for xlsx in Name give a try on *xlsx*

All file names which contain xlsx. Including ans excluding their file extensions.

@Kamalen_Reddy

You can check as below

If you want to check what item is return, check below, it will return full path of the file

Hope this helps

Thanks

1 Like

Thank you All,

I went with the following approach:

image

Where

> ExcelFilePath = Directory.GetFiles(Environment.CurrentDirectory)

2 Likes

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