How to create and fill a ZIP file using ASP.NET?

后端 未结 9 1830
暖寄归人
暖寄归人 2020-12-14 17:29

Need to dynamically package some files into a .zip to create a SCORM package, anyone know how this can be done using code? Is it possible to build the folder structure dynam

9条回答
  •  悲哀的现实
    2020-12-14 17:46

    #region Create zip file in asp.net c#
            string DocPath1 = null;/*This varialble is Used for Craetting  the File path .*/
            DocPath1 = Server.MapPath("~/MYPDF/") + ddlCode.SelectedValue + "/" + txtYear.Value + "/" + ddlMonth.SelectedValue + "/";
            string[] Filenames1 = Directory.GetFiles(DocPath1);
            using (ZipFile zip = new ZipFile())
            {
                zip.AddFiles(Filenames, "Pdf");//Zip file inside filename
                Response.Clear();
                Response.BufferOutput = false;
                string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
                Response.ContentType = "application/zip";
                Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
                zip.Save(Response.OutputStream);
                Response.End();
            }
            #endregion
    

提交回复
热议问题