Can't delete png.file because it is in use by other processes

Hey Community,

I installed the method from this topic into my robot to adjust the image size. Since I want to use the newly generated image and not the old one, I try to delete it using the delete-activity. However, I get the message: The process cannot access the file because it is being used by another process.

The deletion does not take place immediately but much later. I still get this message. Can it be that the image remains open in the “invoke Method method” or via “system.Drawing.Image.FromFile”? I can’t explain it at all and I hope that you can help me in this matter.

thanks in advance and best regards

Hi@aytac22
Can you show me code or file so i can see what you are doing and where you are facing issue.

Hi Raja,

here is the sequence:

It is the same sequence code from here

Later then i want to delete the old one:

I can only delete it when the robot stops working.

Nobody can help?

@aytac22 first of all sorry for late reply …yesterday I was not online.
Can you run in debug mode and point out where you are facing issue

Hello @aytac22
Try this, it may helps you
Kindly use For Each File in Folder activity and use the Delete File activity in the loop
Use “.png” in filter
image

Run the resizing procerure as a separate workflow (using InvokeWorkflow) with “Isolate” option ON.

Cheers

Seems to be a lot of issues lately where activities don’t let go of the file like they should. Put this right before you try to delete the file, to force it to “let go”:

image

The second one is WaitForPendingFinalizers

2 Likes

Good trick! It works

Please mark as solution