从 Azure blob 存储下载 Grid/Telerik Rad 的多个选定文件

Download multiple selected files of Grid/Telerik Rad from Azure blob storage

我有一个网格 view/telerik rad 网格,每行都有复选框,用户可以在其中选择他们需要下载的任何文档,并且在网格外有一个正常的 asp.net 按钮,可用于从 Azure Blob 下载所有选定的文件到用户 computer.I 使用 ICSharpCode.SharpZipLib.Zip 从 nuget 包,它没有 work.No 错误,但没有下载任何 files.Any 解决方案? .

Imports ICSharpCode.SharpZipLib.Zip


 Protected Sub downloadbutton_Click(sender As Object, e As EventArgs) Handles downloadbutton.Click

             Response.AddHeader("Content-Disposition", "attachment; filename=" + "myfilezip" + ".zip")
              Response.ContentType = "application/zip"
               Using zipStream As ZipOutputStream = New ZipOutputStream(Response.OutputStream)

                For Each item As Telerik.Web.UI.GridDataItem In grid.Items

                    If CType(item.FindControl("myCheckBox"), CheckBox).Checked Then

            Dim blockBlob As CloudBlockBlob = GetStorageAccountDetails.GetBlockBlobReference(""container info and file path)

                Dim sr as stream= blockBlob.OpenRead()
                     Dim ms As System.IO.MemoryStream = New IO.MemoryStream()
                        sr.CopyTo(ms)
                        Dim buffer As Byte() = ms.ToArray()

                        Dim fileEntry = New ZipEntry(fileName) With {
                            .Size = buffer.Length()
                        }



                        zipStream.PutNextEntry(fileEntry)
                        zipStream.Write(buffer, 0, buffer.Length)
                    End If
                Next


                zipStream.Flush()
                zipStream.Close()

end sub 

我使用了通过 Nuget 包管理器下载的 DotNetZip 库,它运行良好。

Response.Clear()
Response.BufferOutput = False
Dim archiveName As String = "myfile.zip"

Response.ContentType = "application/zip"
Response.AddHeader("content-disposition", "filename=" + archiveName) 
Dim i as integer=1 
 Using zipDownload1 As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
    For Each item As Telerik.Web.UI.GridDataItem In Grid.Items

        If CType(item.FindControl("mycheckbox"), CheckBox).Checked Then

         Dim blockBlob As CloudBlockBlob = GetStorageAccountDetails.GetBlockBlobReference(""container info and file path)

        Dim sr as stream= blockBlob.OpenRead()
             Dim ms As System.IO.MemoryStream = New IO.MemoryStream()
                sr.CopyTo(ms)
                Dim buffer As Byte() = ms.ToArray()


            zipDownload1.AddEntry("fileName"+i.tostring(), buffer) 
            i=i+1

        End If
    Next


    zipDownload1.Save(Response.OutputStream)

    Response.Close()


End Using