Delete File Problem

Hi Forum,

I’m facing a problem when I loop and try to delete a list of xlsm files in local Desktop PC. Since last Friday some of the files can take up to 3 or 4 minutes to delete. It works fine before though. The file size is maximun 20MB . The RPA code is as below:
image

Anyone please help :slight_smile:

and by the way, the code is developed on Studio Ver: 2018.4.6.
The count of “xlsm” file to delete is around 20 files. :slight_smile:

@caoshixiao1

previously how much time did it take to finish the process?

Thanks

Previously it won’t take more than 1 min :rofl:

Hi @caoshixiao1

Since you are applying filter after each files it getting slow

Try using the filter condition like below
Directory.GetFiles(“Your filepath”, “*.xlsm”) in assign

and try to delete file item.

Hope this reduce your time consumption!

Regards

@caoshixiao1, give it a try with the below expression.

Array.ForEach(Directory.GetFiles(DirectoryPath),Sub(x) File.Delete(x))

P.S. Use the above expression in InvokeCode activity

It works fine before, so I dun think its the coding problem. I gona try the Command line to delete the files.

Hi, I would like to delete the files which ends with “.xlsm”, how can I do the code?

Use like this - Array.ForEach(Directory.GetFiles(DirectoryPath,"*xlsm",System.IO.SearchOption.AllDirectories),Sub(x) File.Delete(x))

Cheers, It works perfectly :clap:

1 Like

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