Try catchアクティビティの中でInputファイルが開いていることを検知して異常終了させたい

Try catchアクティビティの中でInputファイルが開いていることを検知して異常終了させるWFを作成中です。下記で動くでしょうか?

まず、アプリのステートを確認アクティビティで、Inputファイルの一部を検出して、Terminate Workflowアクティビティを実行します。(添付画像参照。Reasonにはメッセージボックスに表示させる文言を記述し、Exceptionには、New NodeNotFoundException と書きます。)
次に、Catch BlockにNodeNotFoundException を追加し、メッセージボックスに変数exec_exception.message を記述します。(添付画像参照)


Dear,

Normally Try Catch activity is used to catches a specified exception type in a sequence or activity, and either displays an error notification or dismisses it and continues the execution.

In your case i believe you need to check for a file and if the file is not available you have to terminate workflow.

Use “If” Activity with File.Exists(File Path in double quotes) example:(File.Exists(“C:\Users\MYDrive\Downloads\RPA.pptx”))

image

in the else part you can call terminate workflow activity :slight_smile:

Regards MRMK

Mark as solution if found helpful

Hi, Thank you for your reply.
First, I will show you your misunderstanding…
I did not intended to check file exists, but I intended to check file was opened or not instead.
Pls advise me under this circumstances.

Regards,
gorby

Dear @gorby

From the screenshot it looks like you are checking for an excel file. Use read workbook activity inside a try catch block. Workbook activity will throw an error if the file is already opened.
in the catch section defile system.exception then log and terminate as you like.

Regards,
MRMK