如何在vb.net中以zip格式下载多个文件。在firefox中下载时丢失了我的扩展程序

时间:2017-01-05 02:58:56

标签: vb.net

我在vb.net中将多个文件作为zip文件下载。某些浏览器不会将其添加为zip文件。

我的代码是:

If Not IsPostBack Then
        If Not Session("x") = Nothing Then
            Dim x As String = Session("x").ToString
            Dim path() As String
            path = x.Split("|"c)
            Using zip As New ZipFile()
                zip.AlternateEncoding = Encoding.UTF8
                zip.AlternateEncodingUsage = ZipOption.AsNecessary
                For i = 0 To UBound(path)
                    If Len(path(i)) > 0 Then
                        Dim filePath As String = Trim(path(i))
                        zip.AddFile(filePath)
                    End If
                Next
                Response.Clear()
                Response.BufferOutput = False
                Dim zipName As String = [String].Format _
                 ("Datas_{0}.zip", DateTime.Now.ToString("dd-MMM-yyyy"))
                Response.ContentType = "application /zip"
                Response.AddHeader("content-disposition", "attachment;filename=" + zipName + "")
                zip.Save(Response.OutputStream)

                HttpContext.Current.ApplicationInstance.CompleteRequest()

                Response.Flush()
                Session.RemoveAll()
                Session.Clear()
                Session.Abandon()

            End Using
        Else
            Response.Redirect("frmUser.aspx")
        End If
    End If

我的文件正在Chrome和IE中作为zip文件下载但是在Firefox中它有时会下载为xml文件,有时它的下载没有任何扩展名。我不知道实际的问题是什么?

0 个答案:

没有答案