Ionic Zip在实时服务器上不起作用,但在C#Asp.net中的本地主机上

时间:2019-05-24 10:01:18

标签: c# downloadfile ionic-zip

我正在使用离子zip下载zip文件,它在localhost上运行良好。但是在实时服务器上,下载的zip文件无法打开。Zip文件的下载大小也很小。

using (ZipFile zip = new ZipFile())
            {
                zip.AlternateEncodingUsage = ZipOption.AsNecessary;
                zip.AddDirectoryByName("Notes");
                Response.Clear();
                Response.BufferOutput = false;
                string archiveName = String.Format("IlmkiDunya_Notes_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
                Response.ContentType = "application/zip";
                Response.AddHeader("content-disposition", "filename=" + archiveName);
                Int64 fileSizeInBytes = 0;
                foreach (var item in ListOfNoteImages)
                {
                    fileSizeInBytes = fileSizeInBytes + new FileInfo(item).Length;
                }
                Response.AddHeader("Content-Length", fileSizeInBytes.ToString());

                zip.AddFiles(ListOfNoteImages, "Notes");
                zip.Save(Response.OutputStream);
                Response.Close();
            }

0 个答案:

没有答案