admin管理员组

文章数量:1289565

For some reason the zip file is always empty. zipInMemory.Length = 0 but below shows the zip with 2 entries... zipArchive

`Response.Clear()
Response.BufferOutput = False
Dim zipFileName As String = [String].Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"))
' Create the memoryStream
Using zipInMemory As MemoryStream = New MemoryStream()
    ' Create the zip file in memorystream
    Using zipArchive As New ZipArchive(zipInMemory, ZipArchiveMode.Update)
        ' Add files to be compressed
        For Each drawingdoc As String In drawingdoclist
            If drawingdoc.Trim <> "" Then
                Dim ZipEntry As ZipArchiveEntry = zipArchive.CreateEntry(drawingdoc)
            End If
        Next
        Response.ContentType = "application/zip"
        Response.AddHeader("content-disposition", "attachment; filename=" + zipFileName)
        zipInMemory.WriteTo(Response.OutputStream)
        Response.AddHeader("Content-Length", zipInMemory.Length)
        Response.Flush()
    End Using
End Using`

i've tried finding example with adding multiple files to a zip in a memorystream then outputting to a response. Expected the downloaded zip file to have 2 files in it.

本文标签: systemiocompressionVBNET ZipArchive from MemoryStream empty on responseStack Overflow