DirectoryExists Use Example
Basic DirectoryExists Use
This is an example that if the directory doesn’t exists, then create the directory. Otherwise, do the rest in the process flow.
Using DirectoryExists for Message Attachments
In this example, we examine a feature called the message center. Users with access (like an admin) have the ability to save messages and provide attachments. Then, certain users receive a notification that a new message exist and can be viewed. Upon viewing the message, the attachment is available to all users viewing the new message.
This is done by dynamically checking if a directory already exists and if not, creating a directory based on the MessageId. Each time a message is created, it is first assigned a MessageId. Then, in order to add an attachment, the process puts together the file paths for the “Attachments” parent folder, the “MessageCenter” folder within that, and the “[MessageId]” folder within that (this one may not exist yet if the message is new). This is done in the “Paths” evaluate.
From there it checks if the directory for the MessageId exists with the DirectoryExists service. As mentioned, if the message is new, it won’t exist yet. This is where CreateDirectory is used, for new messages. After finding the MessageId folder exists or creating it, the attachment is saved to that folder.
Here is the DirectoryExists configuration