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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 412
1 sanket saxena 355
2 Abhinav S 258
3 OriginalGriff 235
4 CPallini 205
0 Sergey Alexandrovich Kryukov 8,704
1 OriginalGriff 5,000
2 Peter Leow 3,839
3 Maciej Los 3,535
4 Er. Puneet Goel 3,107


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