Scenario:
On daily basis we get zip files those can contain single file or more than one files of different types. We want to create an SSIS Package that can loop through all zip files and extract the files from them and save them to a folder from where we can load them to different destinations in SSIS Package.
Solution:
In this video we will learn the solution of our given scenario and create an SSIS Package. Below is the list of items we will cover in this video
- How to Loop through zip files in SSIS Package
- How to create Package Parameters for Zip and UnZip folders and use them in Script Task
- How to Change Dot Net Framework from 4 to 4.5 in Script Task
- How to add Assemblies such as System.IO.Compression and System.IO.Compression.FileSystem in Script Task
- How to Extract Files from Zip file to folder and then delete the zip file in SSIS Package by using Script Task
Script used in the video to Unzip the Zip files
public void Main() { string zipfullpath = Dts.Variables["User::ZipFullPath"].Value.ToString(); string inputfolder = Dts.Variables["$Package::InputFolder"].Value.ToString(); using (ZipArchive arch= ZipFile.OpenRead(zipfullpath)) { foreach(ZipArchiveEntry entry in arch.Entries) { entry.ExtractToFile(Path.Combine(inputfolder,entry.FullName)); } } File.Delete(zipfullpath); // TODO: Add your code here Dts.TaskResult = (int)ScriptResults.Success; }
How to Extract Files from Zip Files in SSIS Package - SSIS Tutorial
Related Posts/Videos on Zip / UnZip by Script Task
- How to change .NET Framework version in Script Task and Add Reference to Assembly(ZipFile Demo)
- Load Text Files,Zip them to Folder with Datetime and Delete From Input Directory in SSIS Package
- Load File/s, Zip and Delete from Source Folder in SSIS Package
- Zip ( Compress) Files and Add them to Folder According to Extension in SSIS Package
- Zip or Compress Files according to the Name of Files in SSIS Package
- Get File names from Zip Files and Insert into SQL Server Table in SSIS Package
- How to Zip ( Compress) Multiple Folders and Delete in SSIS Package
- Create Zip file per day with Date Only and Add Files to it in SSIS Package
Getting dts error: DTS Script Task has encounter an exception in user code
ReplyDeleteException has been thrown by the target of an invocation.
ReplyDeleteAmazing, this is great as you want to learn more, I invite to This is my page. Satta result
ReplyDelete