private void ExportToZip() { Response.Clear(); //Response.BufferOutput = false; Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=\"PnLBudgetExport.zip\""); using (ZipFile zip = new ZipFile()) { if (Directory.Exists(Server.MapPath(ZIP_FOLDER))) { foreach (string file in Directory.GetFiles(Server.MapPath(ZIP_FOLDER))) { zip.CompressionMethod = CompressionMethod.None; //int indx = file.LastIndexOf("\\"); //zip.AddEntry(file.Substring(indx), File.ReadAllBytes(file)); zip.AddFile(file, string.Empty); } } zip.Save(Response.OutputStream); } DeleteTempDir(); } where ZIP_FOLDER ="~/ZipExport"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)