Wednesday, May 24, 2017

Files Archiving using Script task in SSIS







Find the below c# code to archive files

To use ZipFile functionality first we need to use  below name spaces at Namespaces section.

using System.IO;
using System.IO.Compression;

If System.IO, System.IO.Compression related dlls not available we need to add it in references tab.

string ArchiveFileName = Dts.Variables["User::ArchivePath"].Value.ToString() +"\\BKP_" + (DateTime.Now.ToString("ddMMyyyyhhmmss"))+".zip";
 

 ZipFile.CreateFromDirectory(Dts.Variables["User::FilePath"].Value.ToString(), ArchiveFileName);


Delete Files from Directory :

Using File System task we can delete files from directory by selecting option Delete directory content .


No comments:

Post a Comment