string[] filePaths = Directory.GetFiles(@"D:\MP_Upload"); string[] FName = new string[filePaths.Length]; int j=0; foreach (string path in filePaths) { FName[j] = Path.GetFileName(path); j++; } using (ZipFile zip=new ZipFile()) { for (int i = 0; i < FName.Length; i++) { string filename = @"C:\Users\user\Downloads\" + FName[i]; string filePath = filePaths[i]; //Server.MapPath(@"D:\MP_Upload" + filename); zip.AddFile(filePath, FName[i]); } Response.Clear(); Response.BufferOutput = false; Response.AddHeader("Content-Disposition", "attachment; filename=chart4d(1).pdf"); Response.ContentType = "application/zip"; zip.Save(Response.OutputStream); Response.End(); }
string SourceFolderPath = System.IO.Path.Combine(FolderPath, "Initial"); Response.Clear(); Response.ContentType = "application/zip"; Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", nameFolder + ".zip")); bool recurseDirectories = true; using (ZipFile zip = new ZipFile()) { zip.AddSelectedFiles("*", SourceFolderPath, string.Empty, recurseDirectories); zip.Save(Response.OutputStream); } Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)