Zipping csv file
Hi, I have created a package,which creates a csv file in a location(like D:\SSIS). I want to zip that csv file using script task. I tried the following vb.net code but unable to zip the file. Can anyone please suggest on this? Imports System Imports System.Data Imports System.Math Imports System.IO Imports System.IO.Compression Imports Microsoft.SqlServer.Dts.Runtime Public Sub Compress(ByVal FilePath As String) FilePath = "D:\VMT\SSIS\TransactionDailyExport\" Dim UncompressedData As Byte() = System.IO.File.ReadAllBytes(FilePath) Dim CompressedData As New MemoryStream() Dim GZipper As New GZipStream(CompressedData, CompressionMode.Compress, True) GZipper.Write(UncompressedData, 0, UncompressedData.Length) GZipper.Dispose() System.IO.File.WriteAllBytes(Left(FilePath, InStr(FilePath, ".") - 1) + ".rar", CompressedData.ToArray) CompressedData.Dispose() Dts.TaskResult = ScriptResults.Success End Sub Thanks, VK
May 7th, 2012 11:58pm

I use DotNetZip: http://dotnetzip.codeplex.com/ to create zip files in .NET, it's more efficient and easy to use. To create a zip file(taken from the site): using (ZipFile zip = new ZipFile()) { // add this map file into the "images" directory in the zip archive zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images"); // add the report into a different directory in the archive zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files"); zip.AddFile("ReadMe.txt"); zip.Save("MyZipFile.zip"); } Randy Aldrich Paulo MCTS(BizTalk 2010/2006,WCF NET4.0), MCPD | My Blog BizTalk Message Archiving - SQL and File Automating/Silent Installation of BizTalk Deployment Framework using Powershell > Sending IDOCs using SSIS
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2012 12:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics