Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
In my solution expolrer i ve stored my uploaded files. In a single button click how to i download all files in a zip format??
 
protected void Page_PreRender(object sender, EventArgs e)
{
try
{
ArrayList[] files = new ArrayList[40];
for (int j = 0; j < 40; j++)
{
files[j] = new ArrayList();
}
int DptID = int.Parse(Session["MyDptID"].ToString());
int SubID = int.Parse(Session["MySubID"].ToString());
string Assignment = Session["Assignment"].ToString();
string Year = Session["Year"].ToString();
SqlAdapter = new SqlDataAdapter("select * from StudentsAccounts where DepartmentID='" + DptID + "' And Year='" + Year + "'", Connection);
DataSet MyDataSetStudentsAccounts = new DataSet();
SqlAdapter.Fill(MyDataSetStudentsAccounts, "StudentsAccounts");
DataList1.DataSource = MyDataSetStudentsAccounts.Tables [0];
DataList1.DataBind();

for (int i = 0; i {
string MyFolderName = MyDataSetStudentsAccounts.Tables[0].Rows[i][0].ToString() + MyDataSetStudentsAccounts.Tables[0].Rows[i][2].ToString();
StudentName = "( " + MyDataSetStudentsAccounts.Tables[0].Rows[i][1].ToString() + " )" + MyDataSetStudentsAccounts.Tables[0].Rows[i][2].ToString();
 
PathFolder[i] = "~/Students Assignments/" + MyFolderName + "/" + SubID + Assignment;
CustomerFolder = MyFolderName + "/" + SubID + Assignment;
string AssName=SubID + Assignment;
DirectoryInfo Mydir = new DirectoryInfo(Server.MapPath("~/Students Assignments/") + MyFolderName);
int val = 0;
if(Mydir.GetDirectories().Length !=0)
{
DirectoryInfo[] folderList = Mydir.GetDirectories();
foreach (DirectoryInfo di in folderList)
{
if (di.Name == AssName)
{
val = 0;
}
else
{
val = 1;
Image Word = (Image)DataList1.Items [i].FindControl("ImageWord");
Word.Visible = false;
}
}
if (val == 0)
{
Image Word = (Image)DataList1.Items[i].FindControl("ImageWord");
Word.Visible = true ;
DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/Students Assignments/") + CustomerFolder);
DataList DL2 = (DataList)DataList1.Items[i].FindControl("DataList2");
FileInfo[] MyFiles = dir.GetFiles();
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
DataColumn dc1 = new DataColumn();
dc.ColumnName = "Path";
dt.Columns.Add(dc);
dc1.ColumnName = "DocName";
dt.Columns.Add(dc1);
for (int k = 0; k < MyFiles.Length; k++)
{
DataRow dr = dt.NewRow();
dr["Path"] = "~/Students Assignments/" + MyFolderName + "/" + SubID + Assignment + "/" + MyFiles[k].Name;
dr["DocName"] = MyFiles[k].Name;
dt.Rows.Add(dr);
}
 
DL2.DataSource = dt;
DL2.DataBind();

}
}

}

}
catch (Exception ex)
{
throw ex;
}
}
 

here i assigned single file into datalist. how to call the file folder and convert it to zip??
Posted 24-Dec-12 19:56pm
Edited 24-Dec-12 20:08pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

As per my knowledge, one click = one file download or else you got to zip it.
for zip http://msdn.microsoft.com/en-us/library/system.io.packaging.package.aspx
http://metadeveloper.blogspot.in/2008/10/better-know-framework-zip-package.html (Its a console app but you will get a reference)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100