Download Multiple Files in a Single Archive with RadZipLibrary

Thread is closed for posting
1 posts, 0 answers
  1. BC36940A-3DDA-4D74-9EDF-0CC5B44D1CAB
    BC36940A-3DDA-4D74-9EDF-0CC5B44D1CAB avatar
    11 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2018 Link to this post


    Telerik Product and Version


    Supported Browsers and Platforms

    All browsers supported by Telerik UI for ASP .NET AJAX

    Programming language



    This sample demonstrates how to download multiple files from various formats within a single .zip archive by making avail of the Telerik's RadZipLibrary control. In order to use this zip library, you can include the required assemblies as explained in this article:
    Telerik ZIP Library 

    You can find the original more advanced version of this implementation in the following live demo:
    RadZipLibrary Overview

    Zip Library Archive

    Code-behind logic:

    Protected Sub RadButton1_Click(sender As Object, e As EventArgs)
            Dim memStream As New MemoryStream()
            Using archive As New ZipArchive(memStream, ZipArchiveMode.Create, True, Nothing)
                For Each docFile As String In Directory.GetFiles(HttpContext.Current.Server.MapPath("~/Files"))
                    Using entry As ZipArchiveEntry = archive.CreateEntry(Path.GetFileName(docFile))
                        Using writer As New BinaryWriter(entry.Open())
                        End Using
                    End Using
            End Using
        End Sub
        Private Sub SendZipToClient(memStream As MemoryStream)
            memStream.Seek(0, SeekOrigin.Begin)
            If memStream IsNot Nothing AndAlso memStream.Length > 0 Then
                Response.AddHeader("content-disposition", "attachment;")
                Response.ContentType = "application/zip"
            End If
        End Sub

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.