In this case, the Operation property is set to Move file, which should move a file from a working
source path to an archive destination path. The IsDestinationPathVariable property enables you to
specify whether the destination path will be set to an SSIS variable or use a Connection Manager. If
this is set to true, the dynamic property DestinationVariable sets the destination path to a variable.
If it is set to false, then the DestinationConnection option will be available so you can select the
Connection Manager that contains your file or directory. These same properties exist for the source
connection in the bottom of the tab. The OverwriteDestination option, set to false by default,
specifies whether the task will overwrite the destination file or directory if it already exists. To get
an idea of how you configure this task, see the example in the next section.
Archiving a File
Consider a typical use of the File System Task for an ETL process from a mainframe system. To
automate a nightly data load, the process would look like this:
1. A file or series of similar files would be generated from a mainframe or other source system
and dumped to a network drive.
2. An SSIS package would start on a schedule to poll a directory looking for files to process. If
any files were found, they would be moved into a staging or working directory.
3. The data would be extracted out of the file(s).
4. The file(s) would then be archived to another directory.
In legacy DTS packages, each of these steps would require some coding in the ActiveX Script Task.
You would have to write one task in VBScript to poll the directory to determine whether the file
arrived. Another script would pick up the file and move it to another directory. The last script would
archive the file. Even worse, the ActiveX scripts had to use the code-and-paste method of code reuse
to perform the same function in other packages. Typically, this led to various states of unfinished
code that was better in some packages than others and most certainly a nightmare to maintain.
In SSIS, the File System Task can simplify the creation of a package by performing these ETL filebased
requirements. We’ll postpone the task of polling until later in this chapter when we get to the
WMI Event Watcher Task. The iteration of files is also discussed in detail in Chapter 6. However,
you can use what you know about the File System Task to move the file to an archive directory.
1. Create a new project named Tasks and a package in c:ProSSISTasksFileSystemTask
or download the complete code from www.wrox.com/go/prossis2014.
2. Create a subdirectory called c:ProSSISTasksFileSystemTaskArchive, and create a
dummy file called myfile.txt in c:ProSSISTasksFileSystemTask.
3. Add a File System Task into the Control Flow.
4. In the new task, change the operation to Move File. Select from the
SourceConnection dropdown.
5. When the File Connection Manager Editor opens, select Existing File and type C:ProSSIS
TasksFileSystemTaskMyFile.txt for your file.