Tuesday, February 5, 2013

Copy all files of the folder/directory in SSIS

File System Task does not have option for Copy the content of directory. Fortunately this can be easily achieved  with the help of Operation called Copy Directory in File System Task.

To accomplish this just mention Source folder and Destination folder path in the File System Task.

To start with, Create 2 variables
1. dest_path 
            Value : C:\WORK\Dest\ (or any other required destination path)
2. Source_Path
            Value : C:\WORK\Source\DATA (or any other required source path)

Now set these variables in File System Task

Double click on File System Task to edit the configurations.

In General Section,

Set the Operation to Copy Directory. Now,

set up these properties.

IsDestinationPathVariable : True
DestinationVariable : dest_path

IsSourcePathVariable : True
SourceVariable : Source_Path

OverwriteDestination : True (based on your requirement)

Thats it. Execution of File System Task will copy all the files exists in DATA folder to Destination folder C:\WORK\Dest\ including subfolders and subfolder content.

If you would like to create different folder at destination, you can do this by mentioning 
the new folder name in destination path as following statement.

C:\WORK\Dest\DATA_Dest

This example use variable to keep folder paths. for the same operation we can use File Connection manager.



Happy coding :)

No comments:

Post a Comment