Try This
Html
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AJAX FileUpload</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div align="center">
<div style="font-family:Calibri"><b><h2>AJAX FileUpload</h2></b></div>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server" MaximumNumberOfFiles="10" OnUploadComplete="File_Upload" Width="500px" />
</div>
<div align="center">
<asp:Button ID="btnSee" runat="server" onclick="btnSeeAllFiles_Click" Text="Display Files" />
<asp:CheckBoxList ID="checkBoxList" runat="server"/>
<asp:Button ID="btnDownload" runat="server" onclick="btnDownload_Click" Text="Download Files" />
</div>
</form>
</body>
</html>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using System.IO;
using Ionic.Zip;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
checkBoxList.Visible = false;
btnDownload.Visible = false;
}
protected void File_Upload(object sender, AjaxFileUploadEventArgs e)
{
string filename = e.FileName;
string strDestPath = Server.MapPath("~/Documents/");
AjaxFileUpload1.SaveAs(@strDestPath + filename);
}
protected void btnDownload_Click(object sender, EventArgs e)
{
ZipFile multipleFiles = new ZipFile();
Response.AddHeader("Content-Disposition", "attachment; filename=DownloadedFile.zip");
Response.ContentType = "application/zip";
foreach (ListItem fileName in checkBoxList.Items)
{
if (fileName.Selected)
{
string filePath = Server.MapPath("~/Documents/" + fileName.Value);
multipleFiles.AddFile(filePath,string.Empty);
}
}
multipleFiles.Save(Response.OutputStream);
}
protected void btnSeeAllFiles_Click(object sender, EventArgs e)
{
checkBoxList.Visible = true;
btnDownload.Visible = true;
DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Documents"));
FileInfo[] filesInFolder = directory.GetFiles("*.*", SearchOption.AllDirectories);
foreach (FileInfo fileInfo in filesInFolder)
{
checkBoxList.Items.Add(fileInfo.Name);
}
}
}