TKC Blog
15

I've searched in the past a few times for a simple to use zip library that can be incorporated into and ASP.net 2.0 application.  And I've finally come across on that's simple to use.  It's called the Ionic zip library, download it here:

http://www.codeplex.com/DotNetZip

Download and install the package and put the Ionic.zip.dll in your application's Bin folder.  I actually chose to use Ionic.zip.reduced.dll which is a version with a smaller foot print.

Here is an example usage from VB.net.

Use the following include:

    Public Shared Sub ZipFiles()

        Dim zip As ZipFile
        Dim ZipExists As Boolean = False
        ' If the archive exists use it, otherwise create a new one

        If File.Exists("c:\temp\test.zip") Then
            zip = ZipFile.Read("c:\temp\test.zip")
            ZipExists = True
        Else
            zip = New ZipFile
        End If

        ' Add the files
        If ZipExists Then
            zip.UpdateFile("c:\temp\test1.txt")
            zip.UpdateFile("c:\temp\test2.txt")
        Else
            zip.AddFile("c:\temp\test1.txt")
            zip.AddFile("c:\temp\test2.txt")
        End If

    End Sub

Search Blog