Hi there,
I have a database which contains the paths of different files, what I want to do is to store the paths in an array to create an array of paths then download these files with one click.

How to do that?
please help

What do you have so far? What do you need help with?

how to download multiple files with one click, I have the paths in an array

Loop the array, get the files.

i did that but got nothing

this is the code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim i As Integer = 0
            Dim pp() As String = {"F:\New folder (2)\1. pdf", "F:\New folder (2)\2.txt", "F:\New folder (2)\3.docx"}
            Dim files As New List(Of ListItem)()
            For Each filePath As String In pp
                files.Add(New ListItem(pp(i)))
                i = i + 1
            Next
            GridView1.DataSource = files
            GridView1.DataBind()
        End If
    End Sub

    Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownload.Click
        Using zip As New ZipFile()
            zip.AlternateEncodingUsage = ZipOption.AsNecessary
            zip.AddDirectoryByName("files")
            For Each row As GridViewRow In GridView1.Rows
                Dim filePath As String = TryCast(row.FindControl("lblFilePath"), Label).Text
                zip.AddFile(filePath, "files")
            Next
            Response.Clear()
            Response.BufferOutput = False
            Dim zipName As String = [String].Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"))
            Response.ContentType = "application/zip"
            Response.AddHeader("content-disposition", "attachment; filename=" + zipName)
            zip.Save(Response.OutputStream)
            Response.[End]()
        End Using
    End Sub

solved
thanks to myself

Care to share your solution, to help others in the future?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.