How to throw Error if files not found in Directory

hi,
i have multiple pdf files in there in “INPUT” folder.
once i read directory pdf files in for each loop if there are pdfs it will read all files. and move to success folder
if No Pdf files in there in directory . i want to show error and send email to use TRY catch activity

how to do this ?

Hi @Anand_Designer

I think u can do it without using try catch too

Like first use the below assign activity to get all pdf files

file_list = Directory.GetFiles(folderpath,“*.pdf”)

file_list is an array containing PDF file path

Then use an if Condition with condition as

file_list.Count<>0

If the condition is true , then in then section loop through all files using for each activitiy

If the condition is false , then in else section u can use mail message activitiy to send email

Or

if u want to use try catch too, then in else section use throw activity to throw a New BusinessRuleException and in catch section corresponding to that exception use mail message activitiy to send an email regarding no files found

Hope it helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed::relaxed:

2 Likes

i tried 1st method its working
but second method using try catch activity in catch block it doesn’t catch error and mail activity … how to use in catch block ?

Can u share screenshot of how u did for 2nd method

2 ND method is same as first one but difference is that u need to surround ur Workflow sequence in try catch

and in else section add business rule exception by using throw activity and in catch section add business exception and in corresponding section use mail message activitiy

it is working … Thanks @NIVED_NAMBIAR

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.