using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Configuration; using System.Data.SqlClient; using System.Threading; using System.Text; using System.IO; using System.Net; using Oracle.ManagedDataAccess.Client; using System.Globalization; using Ionic.Zip; public partial class ACD_Test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Zipdownloadfile(Main.ServerPath() + @"TempFile\Income_statement_AACS\Iqube", "sqmr"); } public static string Zipdownloadfile(string pathdownload, string filenamezip) { var logerror = ""; try { using (ZipFile zip = new ZipFile()) { zip.AlternateEncodingUsage = ZipOption.AsNecessary; string[] ArrayFile = Directory.GetFiles(pathdownload); foreach (string NameFile in ArrayFile) { zip.AddFile(NameFile, filenamezip); } System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.BufferOutput = false; System.Web.HttpContext.Current.Response.ContentType = "application/zip"; System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filenamezip + ".zip"); zip.Save(System.Web.HttpContext.Current.Response.OutputStream); foreach (string NameFile in ArrayFile) { File.Delete(NameFile); } System.Web.HttpContext.Current.Response.Flush(); System.Web.HttpContext.Current.Response.SuppressContent = true; System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); } } catch (Exception ex) { logerror = ex.Message.ToString(); } return logerror; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)