SSIS: File Monitoring

Using a For Loop and Script Task objects to monitor the file system.

In this example, I’ll illustrate how to use a For Loop container to wrap a Scrip Task object which iteratively monitors the file system for the presence of a file and once found, uses another Script Task object to notify the user.

I’ll begin my adding a variable which will be used to communicate a condition between the objects of this package – whether or not the file has been found.

1-script-file-monitoring

Now I will add a For Loop Container which will contain a task that will iterate through a folder I determine, looking for the file I specify.
Notice that I’ve renamed the container so it’s purpose is intuitive to another developer.

2-script-file-monitoring

Inside the For Loop I will drag a Script Task and rename it to illustrate its purpose.

3-script-file-monitoring

By double-clicking the task, I’m able to set the ReadWriteVariable to use my new custom variable.

4-script-file-monitoring

Also, I am able to “Edit the Script” to add my own custom C# which check my folder for the presence of a file and when it’s found, sets my variable to ‘1’.

Next, I’ll add another Script Task which will notify me when my file has been detected once I “Edit the Script” for it.

6-script-file-monitoring

7-script-file-monitoring

Once I connect the Success constraint between the For Loop container to the new Script Task, I’m ready to execute.

8-script-file-monitoring

Upon executing my package, the For Loop task remains yellow until I add the file it’s looking for in the folder.

9-script-file-monitoring

Once the file has been detected, I receive a prompt.

10-script-file-monitoring

Now my package has completed its task.

11-script-file-monitoring

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s