How to delete Excel files from download folder except one particular files?

Example: Location:C:\Users\Downloads
Test.Xlsx
Test2.xlsx
Test3.xlsx
Export to excel.xlsx
I need to delete the Excel files except “Export to Excel” this file

Hi @SND0912

Try this

Path.GetFileName(CurrentFile.ToString).Equals("Export to Excel.xlsx")

Regards,

Hi @SND0912

You can use the below code in Invoke Code:

Directory.GetFiles(folderPath, "*.xlsx").
    Where(Function(file) Not Path.GetFileName(file).Equals("Export to excel.xlsx", StringComparison.OrdinalIgnoreCase)).
    ToList().ForEach(Sub(file) IO.File.Delete(file))

Invoked Code Arguments:

Regards