Код: Выделить всё
var zipfilep = CreateZipFile(fileByteArrays, sfileNames);
if (File.Exists(zipfilep))
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/zip";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(zipfilep));
byte[] fileBytes = File.ReadAllBytes(zipfilep);
HttpContext.Current.Response.BinaryWrite(fileBytes);
HttpContext.Current.Response.Flush();
File.Delete(zipfilep);
}
-------------------------
public string CreateZipFile(List files, List sfileNames)
{
string tempFolder = Server.MapPath("~/Upload");
string zipFilePath = Path.Combine(tempFolder, GetGlobalResourceObject("GestioneContabilita", "RDLCViewer_ZipReportName").ToString() + ".zip");
using (Package zip = Package.Open(zipFilePath, FileMode.Create))
{
for (int i = 0; i < files.Count; i++)
{
string zipPartUri = $"/{Uri.UnescapeDataString(sfileNames[i])}";
Uri partUri = PackUriHelper.CreatePartUri(new Uri(zipPartUri, UriKind.Relative));
PackagePart part = zip.CreatePart(partUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal);
using (Stream partStream = part.GetStream())
{
partStream.Write(files[i], 0, files[i].Length);
}
}
}
return zipFilePath;
}
Windows не может открыть папку. C: \ users \ userprofile \ downloads \ reports.zip недействителен
, а также я проверил отчеты на Server.mappath ("~/upload") имеет размер 15 175 КБ, но после httpcontext .Current.Response.binaryWrite (FileBytes); В C: \ users \ userprofile \ downloads \ storptions.zip это превращается в 15 569 кб < /p>
Что может быть проблемой?
Мне нужно использовать .netframeowrk 4.0 < /p >
blockquote < /p>
< /blockquote>
Подробнее здесь: https://stackoverflow.com/questions/794 ... in-c-sharp
Мобильная версия