Try Catch With For Each File Loop


#1

Scenario: Convert Pdf files to txt files using read pdf with ocr. If ocr runs into an exception, move file to another folder and continue with For Each File Loop

Steps to reproduce: Use Try Catch Activity. Any try sequence that includes file and the include “Move File Activity” in the catch section

Current Behavior: Cannot manipulate file when using try catch because of exception: “File is being used by another process”

Expected Behavior: Move File and go on to next file in directory

Studio/Robot/Orchestrator Version: latest Version

Last stable behavior:
Last stable version:
OS Version: Windows 10 Pro
Others if Relevant: (workflow, logs, .net version, service pack, etc):

Can someone please give me a clear solution. I have been stuck on this issue for a while now. I dont know how im supposed to make sure the process isnt using the file when im trying to use the “Move File Activity” in the catch section of the Try Catch Activity.


#2

Can you post your workflow. By the sounds of things, you’re not closing the PDF file before you try to move it. Try stopping the process or closing the document within what ever PDF reader you’re using (e.g. for Adobe Acrobat its File>Close or CTRL+W).


#3

Alternatively put the move in retry scope or after a short delay. It may need a few ticks for filesystem to register handle release.