Why can I not use [Path Exists] as a Conditional activity for the Retry Activity?

I am trying to get my script to wait until a file has been created,
I tried to use the Retry activity that accepts other Activitys with Boolean Outputs as conditions,
but when i try to drag the “Path Exists” activity to the condition area i get a NO icon (the circle with the cross line through it like in no smoking signs)

Is this by design or a bug?

There was a technical answer on here from a long time ago (2017 maybe?) that got into why it isn’t possible. However, there’s an easy workaround for this: Use an ‘IsTrue’ activity and the condition is File.Exists(YourFilePath)

2 Likes

Yeah piggy backing on what Dave mentioned, you can easily create a workaround for the process using the System.IO.File methods. If you want a more long term solution assuming you will need to do this often, you can look into creating your own activity that takes in a file path (or multiple) and a timeout value and continually checks for the files and exits when it’s found.

1 Like

Thanks,
I don’t seem to have the IsTrue activity,
The work around I had in mind was to use a while loop,


but then i don’t have an easy way to get it to fail if the file never appears (it would sit there forever looping)
again I have a work around for that (using a system.diagnostics.stopwatch object)
then triggering an exception when a timeout occurs, I wanted to alert people if this was a bug.

As you say - if I am doing it often then I’ll just have to make my own custom Activity for it :wink:

Thanks for the help guys.

The ‘IsTrue’ activity is part of the Microsoft.Activities package. It has a few nice activities in it that come in handy

1 Like

Just checked it out and yes alot of the activities look very useful. that will do the trick. thanks.

For the while loop, there are two easy options…

  1. You could loop on a counter and just break the loop if the condition is true, and if false, iterate until the counter is over the limit
  2. (Better option in my opinion) Take the System.DateTime.Now and save it as a variable (var1) prior to the loop and then make your loop condition check if the difference between the new current time (checked within the loop) from System.DateTime.Now and var1 is greater than your time constraint. You would still break the loop if the file is created though so you don’t get stuck in the loop.

The image below shows an example of the second option

EDIT: I would lean towards using what Dave mentioned with the Dowhile if you do not intend to use the activities though!

1 Like

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