File System Task
The File System task performs operations on files and directories in the file system. For example, by using the File System task, a package can create, move, or delete directories and files. You can also use the File System task to set attributes on files and directories. For example, the File System task can make files hidden or read-only.
All File System task operations use a source, which can be a file or a directory. For example, the file that the task copies or the directory it deletes is a source. The source can be specified by using a File connection manager that points to the directory or file or by providing the name of a variable that contains the source path. For more information, see File Connection Manager and Integration Services (SSIS) Variables.
The operations that copy and move file and directories and rename files use a destination and a source. The destination is specified by using a File connection manager or a variable. File system task operations can be configured to permit overwriting of destination files and directories. The operation that creates a new directory can be configured to use an existing directory that has the specified name instead of failing when the directory already exists.
The File System task includes a predefined set of operations. The following table describes these operations.
Copies a folder from one location to another.
Copies a file from one location to another.
Creates a folder in a specified location.
Deletes a folder in a specified location.
Delete directory content
Deletes all files and folders in a folder.
Deletes a file in a specified location.
Moves a folder from one location to another.
Moves a file from one location to another.
Renames a file in a specified location.
Sets attributes on files and folders. Attributes include Archive, Hidden, Normal, ReadOnly, and System. Normal is the lack of attributes, and it cannot be combined with other attributes. All other attributes can be used in combination.
The File System task operates on a single file or directory. Therefore, this task does not support the use of wildcard characters to perform the same operation on multiple files. To have the File System task repeat an operation on multiple files or directories, put the File System task in a Foreach Loop container, as described in the following steps:
Configure the Foreach Loop container On the Collection page of the Foreach Loop Editor, set the enumerator to Foreach File Enumerator and enter the wildcard expression as the enumerator configuration for Files. On the Variable Mappings page of the Foreach Loop Editor, map a variable that you want to use to pass the file names one at a time to the File System task.
Add and configure a File System task Add a File System task to the Foreach Loop container. On the General page of the File System Task Editor, set the SourceVariable or DestinationVariable property to the variable that you defined in the Foreach Loop container.
Reports the operation that the task performs. The log entry is written when the file system operation starts and includes information about the source and destination.
You can set properties through SSIS Designer or programmatically.
For more information about the properties that you can set in SSIS Designer, see the following topics:
For more information about how to set these properties in SSIS Designer, see the following topic:
For more information about how to set these properties programmatically, see the following topic:
Integration Services includes a task that downloads and uploads data files and manages directories on servers. For more information, see FTP Task.