SSIS File System Task

The File System Task is used to manipulate operations on files and directories on a server. For example, you can create the task to create, copy, delete or move a file or a directory. All the operations in the task use a source and some of them, such as copy and move, need a destination as well. Either a source or a destination stands for a file or a directory and can be specified by using a File connection manager or a variable.

Totally 10 operations can be defined in a File System Task and are described in the following table.

OperationDescriptionSpecific Properties
Copy directoryCopy a source folder to a destination folder.IsDestinationPathVariable, DestinationConnection, DestinationVariable, OverwriteDestination
Copy fileCopy a source file to a destination.IsDestinationPathVariable, DestinationConnection, DestinationVariable, OverwriteDestination
Create directoryCreate a source directory.UseDirectoryIfExists
Delete directoryDelete a source directory. 
Delete directory contentDelete all in a source directory. 
Delete fileDelete a source file. 
Move directoryMove a source folder to a destination folder.IsDestinationPathVariable, DestinationConnection, DestinationVariable, OverwriteDestination
Move fileMove a source file to a destination.IsDestinationPathVariable, DestinationConnection, DestinationVariable, OverwriteDestination
Rename fileRename a source file.IsDestinationPathVariable, DestinationConnection, DestinationVariable, OverwriteDestination
Set attributesSets attributes on a file or a folder.Hidden, ReadOnly, Archive, System
  • All the operations contain Name, Description, IsSourcePathVariable, SourceConnection and SourceVariable common properties.
  • Delete directory content operation deletes all the sub folders and files in a folder but not include the folder itself.
  • Delete directory operation deletes a folder including all the sub folders and files in the folder.
  • There is no "Rename directory" operation but "Move directory" can be used to rename a directory.

The following is the list of all the properties in a File System Task.

PropertyDescriptionDefault Value
NameThe name of the task.File System Task
DescriptonThe description of the task.File System Task
OperationThe operation of the task.Copy file
IsSourcePathVariableTrue if the source uses a variable otherwise uses a connection.False
SourceConnectionA source connetion manager which points to a file or a foler. 
SourceVariableA variable which contains a source file or directory. 
IsDestinationPathVariableTrue if the destination uses a variable otherwise uses a connection.False
DestinationConnectionA destination connetion manager which points to a file or a foler. 
DestinationVariableA variable which contains a destination file or directory. 
OverwriteDestinationTrue if the destination can be overwritten.False
HiddenTrue if the file is hidden.False
ReadOnlyTrue if the file is read-only.False
ArchiveTrue if the file is archivable.False
SystemTrue if the file is a system file.False
ExpressionsReplace a property with the result of an expression. 

Before starting to create a sample package, you need to create a TXT file test.txt in the root of C drive. In the sample package, we'll create a folder, move the file text.txt to the folder and at last make the file read-only. Let's do it step by step as follows.

  1. Create a new package in LearnSSIS1 project and rename it to "FileSystemTask.dtsx". Then open the package if it is closed.

  2. Drag and drop the File System Task 3 times from SSIS toolbox to the control flow of the package and link them as shown below.
  3. SSIS Create 3 File System Tasks


  4. Right click the first task and click "Edit..." to open File System Task Editor. Then change the Name to "Create Folder" and Description to "Create a folder from a variable.".

  5. Change the Operation to "Create directory", IsSourcePathVariable to "True" and click in SourceVariable field.
  6. SSIS File System Task Editor


  7. The Add Variable window will be opened and change Name to "Folder" and the Value to "C:\SSIS".
  8. SSIS Add a Variable


  9. Click "OK" to create the variable Folder and click "OK" again to close the File System Task Editor window.

  10. Open the editor of the second task as we did in step 3. Then change the Name to "Move File" and Description to "Move a file to the new folder."

  11. Change the Operation to "Move file", IsDestinationPathVariable to "True" and DestinationVariable to the variable "User::Folder".

  12. Click the drop-down list in SourceConnection and choose to open File Connection Manager Editor. Then click "Browse..." button to choose the test.txt file in the C drive then click "Open" button.
  13. SSIS File Connection Manager Editor


  14. Click "OK" to close the File Connection Manager Editor. You can see a connection manager "test.txt" is added in the Connection Managers area. The settings of the editor looks like below.
  15. Task 2 File Connection Manager Editor


  16. Click "OK" to finish the setting on the second task. We'll set read-only attribute to the file in the last task. But the folder and file have not been created so a new variable to hold the file in the new folder is needed.

  17. Create a new variable File with string type and set its expression as @[User::Folder] + "\\test.txt".
  18. SSIS Variable Setting With Expression


  19. Right click the last task and open the File System Task Editor again. Change the setting as the following.
  20. File Connection Manager Editor Read-only Setting


  21. Click "OK" to close the editor. Then click the "Save" icon to save the whole package.

  22. Run the package you will see it runs successfully. Then click "Stop Debugging".
  23. 3 File Tasks Run Successfully


  24. At last, check the attribute of the file test.txt in the folder C:\SSIS by right clicking the file and choosing properties.
  25. Check File Properties

    You can see the read-only attribute is checked.