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. 

  • 0
    Certified Senior Developer
    in reply to Shubham Aware

    Thank you for the response   I am using move file or folder to final location file system action.

    Which throws the manage exception and produce this error but will try to reconfigure the way you are suggesting. Could you please suggest what could be the possible issue that above file system action is failing

  • 0
    Certified Lead Developer
    in reply to Varad Srivastava

    The “move file or folder” action often fails because the file is locked by another process (like antivirus or an open app), there are permission issues, the destination already has a file with the same name, or the RPA agent isn’t fully connected.
    Ensure no process is using the file, check permissions, confirm destination path is correct and empty, add a short delay after previous file operations, properly close all streams, and verify the RPA agent is running.

Reply
  • 0
    Certified Lead Developer
    in reply to Varad Srivastava

    The “move file or folder” action often fails because the file is locked by another process (like antivirus or an open app), there are permission issues, the destination already has a file with the same name, or the RPA agent isn’t fully connected.
    Ensure no process is using the file, check permissions, confirm destination path is correct and empty, add a short delay after previous file operations, properly close all streams, and verify the RPA agent is running.

Children
  • 0
    Certified Senior Developer
    in reply to Shubham Aware

    I think the main cause is file is locked by another previous action itself we have tried to increase the pause to 1800 seconds which worked once but since then it is failing. What if we do the file deletion manually or perhaps there can be a need to redesign it from the begining it self-

    Here is the process -1 Download zip file from browser

    2. Take out 1 relevant file from the zip and then move it to a location from where it will be picked up another process

    3. Final step to delete the file from the downloads and move it to executed files for RPA folder

    Please let me know what can be best way to achieve this

    Thank you so much for your time!! It's a bit difficult to understand about RPA possible errors but discussion really help a lot.