我正在使用离子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();
}