Delete all files in folder Time problem

Hey! I’m trying to delete all files in a folder, and I’m using an Invoke Code activity with this code: Array.ForEach(Directory.GetFiles(path),Sub(x) File.Delete(x)).
It works perfectly with one file, but once there is more than one, it deletes the files but get stuck in the “Working on it…”. So I added a delay after the delete code so it gives time to File Explorer to complete the task, but even if I give 1 hour, it keeps showing the “Working on it…” message.
Do you have any solution? Thanks !

1 Like

Hi @jadbenn

have you given it in StrArray strarr=Directory.GetFiles(“Your Input FilePath”)
and use for each item in strArray
and then use Delete file activity

Ashwin S

Hi hope these steps could help you resolve this
—use a assign activity like this
arr_filepath = Directory.GetFiles(“yourfolderpath”)
Where arr_filepath is a variable of type array of string
—now use a FOR EACH activity and pass the above variable as input and change the type argument as string
—inside the loop use a DELETE FILE activity and mention the input as item.ToString

Cheers @jadbenn


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