You need to pack files and write a result to a response.
You can use SharpZipLib compression library.
Code example:
Response.AddHeader("Content-Disposition", "attachment; filename=" + compressedFileName + ".zip");
Response.ContentType = "application/zip";
using (var zipStream = new ZipOutputStream(Response.OutputStream))
{
foreach (string filePath in filePaths)
{
byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
var fileEntry = new ZipEntry(Path.GetFileName(filePath))
{
Size = fileBytes.Length
};
zipStream.PutNextEntry(fileEntry);
zipStream.Write(fileBytes, 0, fileBytes.Length);
}
zipStream.Flush();
zipStream.Close();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…