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.
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
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”:
First of all, thanks for the help and tips. I’m also sorry for only now replying. I was on vacation.
I looked at the tips and tried the last one from paul postwick and also from Gokul Jai. However, I do not get the screenshot deleted because it is still being used by the system.
I posted my sequence again. it’s just the one sequence. I get the error message at the end when deleting. What am I doing wrong?
Meldung: Der Prozess kann nicht auf die Datei “C:\Users\Public\Documents\Screenshot.png” zugreifen, da sie von einem anderen Prozess verwendet wird.
Ausnahmetyp: System.IO.IOException
RemoteException wrapping System.IO.IOException: Der Prozess kann nicht auf die Datei “C:\Users\Public\Documents\Screenshot.png” zugreifen, da sie von einem anderen Prozess verwendet wird.
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.File.InternalDelete(String path, Boolean checkHost)
bei System.IO.File.Delete(String path)
bei UiPath.Core.Activities.Delete.Execute(CodeActivityContext context)
bei System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
bei System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
bei System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
The Message is in german and means: The process cannot access the file “C:\Users\Public\Documents\Screenshot.png” because it is being used by another process.