SSIS zip files
Hi, Without installing a 3rd party tool such as Winzip or 7zip, is there a way to have SSIS automatically zip files? I thought there might be a way using .net code (either VB or C#), but i can't find anything out there. Any help would be appreciated. Thanks, Scott
December 19th, 2010 3:03pm

Hi, Try using the following within a SSIS script component; - http://forums.asp.net/p/1086292/1743179.aspx Kind Regards, Kieran.If you have found any of my posts helpful then please vote them as helpful. Kieran Wood MCTS BI, PGD SoftDev (Open), MBCS http://uk.linkedin.com/in/bileeds
Free Windows Admin Tool Kit Click here and download it now
December 19th, 2010 3:14pm

Literally just did this last week as no-one seems to show how to utilise the winXP zip functionality As that link suggests, GZip is available to .NET - I use this function to compress a file: Imports System.IO.Compression Public Sub Compress(ByVal FilePath As String) 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) + ".gz", CompressedData.ToArray) CompressedData.Dispose() End Sub the main issue with this is that the "zipped" files are not readable natively in windows - you can download winzip to open them or you can use 7-Zip (freeware). Either will allow you to re-open the files from windows explorer. you can of course code the extraction of files through .NET as well but as you're asking in an SSIS forum I'm guessing you're more concerned with the archiving of files rather than extracting them again Rgds Geoff
December 19th, 2010 8:46pm

Literally just did this last week as no-one seems to show how to utilise the winXP zip functionality As that link suggests, GZip is available to .NET - I use this function to compress a file: Imports System.IO.Compression Public Sub Compress(ByVal FilePath As String) 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) + ".gz", CompressedData.ToArray) CompressedData.Dispose() End Sub the main issue with this is that the "zipped" files are not readable natively in windows - you can download winzip to open them or you can use 7-Zip (freeware). Either will allow you to re-open the files from windows explorer. you can of course code the extraction of files through .NET as well but as you're asking in an SSIS forum I'm guessing you're more concerned with the archiving of files rather than extracting them again Rgds Geoff
Free Windows Admin Tool Kit Click here and download it now
December 19th, 2010 8:46pm

Geoff's post looks very useful to me.If you have found any of my posts helpful then please vote them as helpful. Kieran Wood MCTS BI, PGD SoftDev (Open), MBCS http://uk.linkedin.com/in/bileeds
December 21st, 2010 12:54pm

You can use SharpZipLib using ICSharpCode.SharpZipLib.Zip; string targetFolder = Dts.Variables["XMLA_Folder_Target"].Value.ToString(); string zipFileName = targetFolder + "XMLA_Archive.zip"; FastZip fZip = new FastZip(); fZip.CreateZip(zipFileName, targetFolder, false, "Files_.*.txt"); Here's an article that will give you more options in using the library: Compressing and uncompressing ZIP files Regards, JasonMCITP BI Developer 2008 - MCTS SQL Server 2005
Free Windows Admin Tool Kit Click here and download it now
December 21st, 2010 1:37pm

Hi, Without installing a 3rd party tool such as Winzip or 7zip, is there a way to have SSIS automatically zip files? I thought there might be a way using .net code (either VB or C#), but i can't find anything out there. Any help would be appreciated. Thanks, Scott The only method is to use the .net comression class: http://msdn.microsoft.com/en-en/library/system.io.compression.aspx, but that only works with gzip. Zip is not supported. You can install Microsoft Visual J# Redistributable Packages (Is Microsoft, so not really third party) and use that dll to zip your files with a Script Task. Here is a C# example: http://microsoft-ssis.blogspot.com/2011/01/zip-sourcefile-to-archive.html
January 8th, 2011 5:26am

video converter to avi 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2011 2:29am

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

Other recent topics Other recent topics