Delete File Using File System Task in SSIS

In this article, we show you how to delete File using File System Task in SSIS with example. To delete Directory, Please refer to Delete Directory Using File System Task article present in the SSIS page.

TIP: To Delete Multiple files, we have to use the For each container.

We have File System Task Folder inside the Music Folder. Our task is to delete a single file (COUNTRIES LOOKUP.xls) present inside the File System Task Folder.

Delete File Using File System Task in SSIS 2014

Delete File Using File System Task in SSIS

To Delete File Using File System Task in SSIS, Drag and drop the File System Task into the Control Flow region and rename it as Delete File Using File System Task

Delete File Using File System Task in SSIS 1

Double click on it will open the File System Task Editor to configure it.

In this example, We are deleting the Single file. So, please change the operation property to Delete File

Delete File Using File System Task in SSIS 2

Let us configure the Source Connection by selecting the SourceConnection property. If you have the File Connection Manager, select it. Or, if you stored the Source Connection in a Variable, change the IsSourcePathVariable Field to TRUE and select the Variable Name.

Here, We are selecting <New Connection..>.

Delete File Using File System Task in SSIS 3

Once you click on the <New Connection..> option, File Connection Manager Editor opened to configure. In this example, we are deleting a single file. So select Existing File option from the Usage Type

Click on the Browse button to select the Existing File (which is Countries Lookup.xls).

Delete File Using File System Task in SSIS 4

From the above screenshot, you can observe that we selected the Excel file called Countries Lookup inside the File System Task Folder

Delete File Using File System Task in SSIS 5

Click Ok to finish configuring the File Connection Manager.

Delete File Using File System Task in SSIS 6

Click Ok to finish configuring File System Task Editor. Let’s run and see whether we successfully deleted the excel file using the File System Task or Not.

Delete File Using File System Task in SSIS 7

Well, We successfully deleted the Countries Lookup file present in the File System Task Folder or Directory.

Delete File Using File System Task in SSIS 8