Ошибка получения файла с ошибкой при загрузке больших файлов с использованием Ionic.zip в c #. Когда пользователь извлекает этот файл, файл отображается как поврежденный. Когда я делаю то же самое с меньшим количеством файлов, чем он работает нормально. Даже это не дает никаких ошибок при создании ZIP-файлов. Я создаю zip-файл из существующих pdf-файлов, которые добавляются в один zip-файл. Может быть 5 файлов или может быть 1000 файлов размером не менее 10 МБ каждый.
Я пробовал с пороговым значением и всеми другими параметрами, представленными в Google, но не нашел никаких решений.
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.Level9;
//zip.AddDirectoryByName("Files");
for (int i = 0; i < dt.Rows.Count; i++)
{
filePath = Convert.ToString(dt.Rows[i]["filePath"]);
fileIds.Add(Convert.ToInt32(dt.Rows[i]["fileid"]));
string fileFullName = Convert.ToString(dt.Rows[i]["fileName"]);
string fName = Convert.ToString(dt.Rows[i]["fileName"]).Split('_')[1];
//ExceptionLogging c1 = new ExceptionLogging("filePath = " + filePath + " fileFullName = " + fileFullName +
// " fName = " + fName);
//c1.ErrorLog(HttpContext.Current.ApplicationInstance.Server.MapPath("~/Logs/"));
if (!fileNamesList.Contains(fileFullName.Split('_')[0]))
{
//ExceptionLogging c2 = new ExceptionLogging("In if condition -- filePath = " + filePath);
//c2.ErrorLog(HttpContext.Current.ApplicationInstance.Server.MapPath("~/Logs/"));
zip.AddFile(filePath, "Files");
fileNamesList.Add(fileFullName.Split('_')[0]);
}
else
{
filePath = filePath.Substring(0, filePath.Length - 4) + "_" + fName;
//filePath = filePath.Split('.')[0] + "_" + fName;
zip.AddFile(filePath, "Files");
fileNamesList.Add(fileFullName);
//ExceptionLogging c3 = new ExceptionLogging("In else condition -- filePath = " + filePath + " fileFullName = " + fileFullName);
//c3.ErrorLog(HttpContext.Current.ApplicationInstance.Server.MapPath("~/Logs/"));
}
//zip.AddFile(filePath, "Files");
}
Response.Clear();
Response.BufferOutput = false;
string zipName = String.Format("ZipFile-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
zip.Save(Response.OutputStream);
//Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
Я должен иметь возможность загружать большие файлы внутри zip.