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
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
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
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..>.
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).
From the above screenshot, you can observe that we selected the Excel file called Countries Lookup inside the File System Task Folder
Click Ok to finish configuring the File Connection Manager.
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.
Well, We successfully deleted the Countries Lookup file present in the File System Task Folder or Directory.