RPA -Throwing error Caused by: java.io.IOException: Failed to delete original file 'C:\Users\user\Downloads\xyz.zip' after copy to 'C:\Users\user\RPA\Executed Files\xyz.zip'

Certified Senior Developer

When I am running RPA it is failing and saying it is failed to delete the file after copying it to the given location. Please help me with the possible cause and fix

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The error occurs because the ZIP file is still locked after copying.
    Add a 1-2 second delay after the copy operation before attempting to delete - this usually fixes it. If not, change your approach to use a "move" operation instead of "copy then delete" which is more reliable.
    Alternatively, implement retry logic that attempts deletion 3 times with delays between attempts. Also check if antivirus is scanning the file and ensure the RPA bot has proper delete permissions on the Downloads folder. 

Reply
  • 0
    Certified Lead Developer

    The error occurs because the ZIP file is still locked after copying.
    Add a 1-2 second delay after the copy operation before attempting to delete - this usually fixes it. If not, change your approach to use a "move" operation instead of "copy then delete" which is more reliable.
    Alternatively, implement retry logic that attempts deletion 3 times with delays between attempts. Also check if antivirus is scanning the file and ensure the RPA bot has proper delete permissions on the Downloads folder. 

Children
No Data