/// <summary> /// Download the file /// </summary> /// <param name="filePath">The file path</param> public static void DownloadFile(string filePath) { filePath = Utilities.FixRoot(filePath); FileInformation = new FileInfo(filePath); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); if (FileInformation.Name.EndsWith(".txt")) { response.ContentType = "text/plain"; } else if (FileInformation.Name.EndsWith(".jpg")) { response.ContentType = "image/jpg"; } if (FileInformation.Name.Equals("readme.html")) { response.TransmitFile(filePath); response.Flush(); response.End(); return; } response.AppendHeader("Content-Disposition", "attachment; filename=\"" + FileInformation.Name + "\";"); response.TransmitFile(filePath); response.Flush(); response.End(); }
//#region 获取上传文件自动生成的文件名 //public static string GetFileName(string str, string eve) //{ // try // { // string name = str.ToLower().Substring(str.LastIndexOf(".") + 1); // if (eve.IndexOf(name) != -1) // { // System.Random rd = new Random(); // string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + DateTime.Now.Millisecond.ToString() + rd.Next(1111, 9999).ToString() + "." + name; // return filename; // } // else // { // JS.MsgBox("上传文件格式错误"); // JS.Back(); // System.Web.HttpContext.Current.Response.End(); // } // } // catch // { // JS.MsgBox("上传文件出错"); // JS.Back(); // System.Web.HttpContext.Current.Response.End(); // return ""; // } // return ""; //} //#endregion #region 防SQL注入式攻击 public static void ModSQL() { System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response; System.Web.HttpRequest Request = System.Web.HttpContext.Current.Request; foreach (string i in Request.Form) { if (i == "__VIEWSTATE") { continue; } if (!modSQL(Request.Form[i].ToString())) { //string tmpPath = System.Web.HttpContext.Current.Server.MapPath("~/log.js"); //FileInfo fi = new FileInfo(tmpPath); //StreamWriter sw = fi.CreateText(); //sw.Write("IP operation:" + Request.UserHostAddress); //sw.Write("Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //sw.Write("Page:" + Request.Url.ToString()); //sw.Write("Parameters:" + i + ""); //sw.Write("Data:" + Request.QueryString[i]); //sw.Flush(); //sw.Close(); Response.Write("<table width=80% align='center' cellpadding='0' cellspacing='0'>"); Response.Write("<tr><td><BR><BR><BR><BR>hackers : Please do not try to inject attack site, the site has implemented safety control, lawless elements will crack down!</td></tr>"); Response.Write("<tr><td>Keep your system has been operational records law:<br></td></tr>"); Response.Write("<tr><td><br>IP operation:" + Request.UserHostAddress + "<br></td></tr>"); Response.Write("<tr><td>Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "<br></td></tr>"); Response.Write("<tr><td>Page:" + Request.Url.ToString() + "<br></td></tr>"); Response.Write("<tr><td>Submit Type:POST<br></td></tr>"); Response.Write("<tr><td>Parameters:" + i + "<br></td></tr>"); Response.Write("<tr><td>Data:" + Request.Form[i]); Response.Write("</td></tr></table>"); Response.End(); } } foreach (string i in Request.QueryString) { if (!modSQL(Request.QueryString[i].ToString())) { Response.Write("<table width=80% align='center' cellpadding='0' cellspacing='0'>"); Response.Write("<tr><td><BR><BR><BR><BR>hackers : Please do not try to inject attack site, the site has implemented safety control, lawless elements will crack down!</td></tr>"); Response.Write("<tr><td>Keep your system has been operational records law:<br></td></tr>"); Response.Write("<tr><td><br>IP operation:" + Request.UserHostAddress + "<br></td></tr>"); Response.Write("<tr><td>Time:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "<br></td></tr>"); Response.Write("<tr><td>Page:" + Request.Url.ToString() + "<br></td></tr>"); Response.Write("<tr><td>Sumbit Type:GET<br></td></tr>"); Response.Write("<tr><td>Parameters:" + i + "<br></td></tr>"); Response.Write("<tr><td>Data:" + Request.QueryString[i]); Response.Write("</td></tr></table>"); Response.End(); } } }
public void ResponseFile(System.Web.HttpResponse response, string fileUId) { Box.CMS.File file = cms.GetFile(fileUId); if (file == null) { response.End(); } response.ContentType = file.Type; response.BinaryWrite(file.Data.StoredData); response.End(); }
public Boolean ExportToPdf( DTO_Template Template, String clientFileName, System.Web.HttpResponse webResponse, System.Web.HttpCookie cookie) { if (Template == null) { return(false); } _template = Template; webResponse.Clear(); //Render effettivo... try { base.WebExport(clientFileName, _template.Settings, webResponse, cookie, Template.Signatures); webResponse.End(); } catch (Exception ex) { string err = ex.ToString(); //DEBUG! return(false); } return(true); }
//---------------------------------------------------------------------------------------------------- /// <summary></summary> /// <param name="report"></param> /// <param name="response"></param> public static void ResponsePDF(Report report, System.Web.HttpResponse response, string fileName) { if (report.formatter == null) { report.Init(new PdfFormatter()); } if (report.page_Cur == null) { report.Create(); } response.Clear(); response.Buffer = true; response.ContentType = "application/pdf"; response.Charset = ""; response.ContentEncoding = System.Text.Encoding.Default; response.ClearContent(); response.AddHeader("Content-Disposition", "filename=" + fileName + ".pdf"); MemoryStream ms = new MemoryStream(); report.formatter.Create(report, ms); ms.Close(); response.BinaryWrite(ms.GetBuffer()); response.End(); }
public static void DownloadFile(System.Web.HttpResponse response, string filePath) { response.Clear(); response.ContentType = "application/x-zip-compressed"; response.TransmitFile(filePath); response.End(); }
public static void RedirectPermanent(this System.Web.HttpResponse response, string uri) { response.StatusCode = 301; response.StatusDescription = "Moved Permanently"; response.AddHeader("Location", uri); response.End(); }
/// <summary> /// Funcion que permite al usuario descargar un archivo /// </summary> /// <param name="respuesta">Response del sitio web</param> /// <param name="datos">Datos a descargar</param> /// <param name="nombre">Nombre del archivo</param> /// <creador>Jonathan Contreras</creador> /// <fecha_creacion>03-10-2011</fecha_creacion> public void DescargarArchivo(System.Web.HttpResponse respuesta, System.IO.MemoryStream datos, String nombre, String tipo, System.Text.Encoding codificacion) { try { nombre = nombre.Replace(" ", "_"); string[] arrCaracteres = { ",", "?", "¿", "'", "!", "¡", "=", "|", "/", "\\" }; for (int intIndice = 0; intIndice < arrCaracteres.Length; intIndice++) { nombre = nombre.Replace(arrCaracteres[intIndice], string.Empty); } byte[] arrDatos = datos.ToArray(); respuesta.Clear(); respuesta.Buffer = true; respuesta.AddHeader("content-disposition", String.Format("attachment;filename={0}", nombre)); respuesta.AddHeader("Content-Length", arrDatos.Length.ToString()); respuesta.Charset = ""; respuesta.ContentType = tipo; respuesta.ContentEncoding = codificacion; respuesta.BinaryWrite(arrDatos); respuesta.Flush(); respuesta.End(); } catch { } }
public void FinishExport(System.Web.HttpResponse response) { Writer.Flush(); // Need to call Response.End() so nothing will be attached to a file // System.Web.HttpResponse.End() function will throw System.Threading.ThreadAbortException // indicating that the current response ends prematurely - that's what we want response.End(); }
private void ExportPdfFile(byte[] pdfBytes, string fileName) { pdfConverter.LicenseKey = SF.Framework.SFConfig.EVOPDFKEY; System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Type", "application/pdf"); response.AddHeader("Content-Disposition", String.Format("attachment; filename=" + fileName + ".pdf; size={0}", pdfBytes.Length.ToString())); response.BinaryWrite(pdfBytes); response.End(); }
public void ProcessRequest(HttpContext context) { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/plain"; response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";"); response.TransmitFile(Server.MapPath("FileDownload.csv")); response.Flush(); response.End(); }
private void DownloadPDF(byte[] downloadBytes, string downloadName) { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Type", "binary/octet-stream"); response.AddHeader("Content-Disposition", "attachment; filename=" + StringHelper.CreateSlug(downloadName) + ".pdf; size=" + downloadBytes.Length.ToString()); response.Flush(); response.BinaryWrite(downloadBytes); response.Flush(); response.End(); }
//public void DownloadFile(Guid? id) public void DownloadFile(string fileName) { //string fileName = fileNameBuilder(id); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/csv"; response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";"); response.TransmitFile("C:\\reports\\" + fileName); response.Flush(); response.End(); }
public void DownloadFile(string fileName, byte[] csvData) { //string fileName = fileNameBuilder(id); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/csv"; response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ";"); response.BinaryWrite(csvData); response.Flush(); response.End(); }
protected void TransmitFile(string filePath, string filename) { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/plain"; response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ";"); response.TransmitFile(filePath); response.Flush(); response.End(); }
/// <summary> /// 把DataTable导出为Word文件 /// </summary> /// <param name="page">Page</param> /// <param name="fileName">Word文件名(不包括后缀*.doc)</param> /// <param name="dtbl">将要被导出的DataTable对象</param> /// <returns></returns> public static bool DataTableToWord(System.Web.HttpResponse response, string fileName, DataTable dtbl) { response.Clear(); response.Buffer = true; response.Charset = "UTF-8"; response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".doc"); response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); response.ContentType = "application/ms-word"; //page.EnableViewState = false; response.Write(DataTableToHtmlTable(dtbl)); response.End(); return(true); }
protected void Button1_Click(object sender, EventArgs e) { CreateBarcodePdf(); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "application/pdf"; response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";"); response.TransmitFile(AppPath + @"Files\Barcode\" + FileName); response.Flush(); //File.Delete(FilePath); //File.Delete(FilePath + ".gif"); response.End(); }
/// <summary> /// Handles a fatal server exception. /// </summary> public static void HandleFatalServerException() { System.Web.HttpResponse resp = System.Web.HttpContext.Current.Response; resp.ClearContent(); resp.StatusCode = 400; resp.AddHeader("Status", "400 Bad Request"); // resp.StatusDescription = "Not Found"; // resp.Write("404 Not Found"); //resp.Flush(); resp.Write("<html><body><strong>The page that you requested caused a server error.</strong><p><em>Please try back later, or try visiting our <a href=\"" + CmsContext.ApplicationPath + "\">home page</a>.</em></p></body></html>"); resp.End(); return; }
protected void btnDownload_Click(object sender, EventArgs e) { //string ten = ViewState["FileName"].ToString().Trim(); string filePath = Format(ViewState["FileName"].ToString().Trim()); System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = ContentType; response.AddHeader("Content-Disposition", "attachment; filename=" + filePath + ";"); response.TransmitFile(Server.MapPath("~/Files/" + filePath)); response.Flush(); response.End(); }
/// <summary> /// สำหรับ Zip ไฟล์และ Download /// </summary> /// <param name="httpResponse">Response ของ Page</param> /// <param name="reqDate">วันที่ต้องการ Download</param> /// <param name="tempFolder">Temp Folder</param> public void DownloadLicenseZip(System.Web.HttpResponse httpResponse, DateTime reqDate, string tempFolder) { //เตรียม Directory และ ไฟล์ที่ต้องการ Download string dir = InitRequestLicenseFileToDownload(tempFolder, reqDate); //สำหรับเก็บ Folder ที่ต้อง Zip เพื่อวนหาไฟล์ใน Folder List <string> list = new List <string>(); list.Add(dir); //วนหา Folder ที่ต้อง Zip และ SubFolder ที่อยู่ภายใน GetAllFiles(list, dir); string folderName = string.Empty; //สร้าง Instantce Zip using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile()) { //กำหนด Option Endcode zip.AlternateEncodingUsage = ZipOption.AsNecessary; //วนเ Folder และ SubFolder for (int i = 0; i < list.Count; i++) { //Folder ปัจจุบัน DirectoryInfo dInfo = new DirectoryInfo(list[i]); folderName += (i == 0 ? "" : "\\") + dInfo.Name; //สร้าง Folder ใน Zip zip.AddDirectoryByName(folderName); //วน Add File ใน Folder foreach (string f in Directory.GetFiles(list[i])) { zip.AddFile(f, folderName); } } httpResponse.Clear(); httpResponse.BufferOutput = false; string zipName = String.Format("{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); httpResponse.ContentType = "application/zip"; httpResponse.AddHeader("content-disposition", "attachment; filename=" + zipName); zip.Save(httpResponse.OutputStream); httpResponse.End(); } }
// calls SetupResponse to set header and cache and saves Excel file to HttpResponse protected internal void SaveExcelBook(System.Web.HttpResponse response) { try { ISDExcelBook.Save(response.OutputStream, response); } catch (Exception ex) { throw ex; } // Need to call Response.End() so nothing will be attached to a file // System.Web.HttpResponse.End() function will throw System.Threading.ThreadAbortException // indicating that the current response ends prematurely - that's what we want response.End(); }
internal static void ThrowWmsException(WmsExceptionCode code, string Message) { System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response; Response.Clear(); Response.ContentType = "text/xml"; Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); Response.Write("<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n"); Response.Write("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) { Response.Write(" code=\"" + code.ToString() + "\""); } Response.Write(">" + Message + "</ServiceException>\n"); Response.Write("</ServiceExceptionReport>"); Response.End(); }
public void ProcessRequest(HttpContext context) { // retrieve your xbook System.IO.MemoryStream ms = new System.IO.MemoryStream(); xbook.Save(ms, C1.C1Excel.FileFormat.Biff8); xbook.Dispose(); ms.Position = 0; System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "application/vnd.ms-excel"; response.AddHeader("Content-Disposition","attachment;filename=CategoryReport.xls"); Response.BufferOutput = true; Response.OutputStream.Write(ms.ToArray(), 0, (int)ms.Length); response.Flush(); response.End(); }
internal static void CreatePDFDocument(DataTable dt, string excelFilename, System.Web.HttpResponse Response) { // // For PDF export we are using the free open-source iTextSharp library. // Document pdfDoc = new Document(); MemoryStream pdfStream = new MemoryStream(); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, pdfStream); pdfDoc.Open();//Open Document to write pdfDoc.NewPage(); iTextSharp.text.Font font8 = FontFactory.GetFont("ARIAL", 7); PdfPTable PdfTable = new PdfPTable(dt.Columns.Count); PdfPCell PdfPCell = null; //Add Header of the pdf table for (int column = 0; column < dt.Columns.Count; column++) { PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Columns[column].Caption, font8))); PdfTable.AddCell(PdfPCell); } //How add the data from datatable to pdf table for (int rows = 0; rows < dt.Rows.Count; rows++) { for (int column = 0; column < dt.Columns.Count; column++) { PdfPCell = new PdfPCell(new Phrase(new Chunk(dt.Rows[rows][column].ToString(), font8))); PdfTable.AddCell(PdfPCell); } } PdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table pdfDoc.Add(PdfTable); // add pdf table to the document pdfDoc.Close(); pdfWriter.Close(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + excelFilename); Response.BinaryWrite(pdfStream.ToArray()); Response.End(); }
/// <summary> /// Exports dataset into CSV / Excel format /// </summary> private void ExportForWeb(DataSet exportDataSet, string[] headerList, string[] filedList, ExportFormat formatType, string fileName) { try { response.Clear(); response.Buffer = true; if (formatType == ExportFormat.CSV) { response.ContentType = "text/csv"; response.AppendHeader("content-disposition", "attachment; filename=" + fileName); } else { response.ContentType = "application/vnd.ms-excel"; response.AppendHeader("content-disposition", "attachment; filename=" + fileName); } MemoryStream memoryStream = new MemoryStream(); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); XmlDataDocument xmlDataDocument = new XmlDataDocument(exportDataSet); XslTransform xslTransform = new XslTransform(); StringWriter stringWriter = new StringWriter(); CreateStylesheet(xmlTextWriter, headerList, filedList, formatType); xmlTextWriter.Flush(); memoryStream.Seek(0, SeekOrigin.Begin); xslTransform.Load(new XmlTextReader(memoryStream), null, null); xslTransform.Transform(xmlDataDocument, null, stringWriter, null); response.Write(stringWriter.ToString()); stringWriter.Close(); xmlTextWriter.Close(); memoryStream.Close(); response.End(); } catch (ThreadAbortException ex) { string ErrMsg = ex.Message; } catch (Exception ex) { throw ex; } }
//download file public void saveFile(System.Web.HttpResponse Response, string PathfileName) { string filename = PathfileName; if (filename != "") { string path = filename; System.IO.FileInfo file = new System.IO.FileInfo(path); if (file.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(file.FullName); Response.End(); } } }
/// <summary> /// Handle PageNotFound (404) errors. /// <para>If the useInternal404NotFoundErrorHandler config entry is true, will send the user to the page /// specified by Internal404NotFoundErrorHandlerPageUrl config entry.</para> /// </summary> public static void HandleNotFoundException() { bool useInternal404NotFoundErrorHandler = CmsConfig.getConfigValue("useInternal404NotFoundErrorHandler", false); if (useInternal404NotFoundErrorHandler) { string defaultUrl = ""; if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null) { defaultUrl = System.Web.HttpContext.Current.Request.Url.PathAndQuery; } string fromUrl = PageUtils.getFromForm("aspxerrorpath", defaultUrl); fromUrl = System.Web.HttpUtility.UrlEncode(fromUrl); string Internal404NotFoundErrorHandlerPageUrl = CmsContext.ApplicationPath + "/_internal/error404.aspx?from=" + fromUrl; if (CmsConfig.getConfigValue("Internal404NotFoundErrorHandlerPageUrl", "") != "") { Internal404NotFoundErrorHandlerPageUrl = String.Format(CmsConfig.getConfigValue("Internal404NotFoundErrorHandlerPageUrl", ""), fromUrl); } // use Server.Transfer (And not Response.Redirect) to hide the CMS URL from the user. System.Web.HttpContext.Current.Server.Transfer(Internal404NotFoundErrorHandlerPageUrl); return; } else { // <?php header("HTTP/1.1 404 Not Found"); ?> // <?php header("Status: 404 Not Found"); ?> System.Web.HttpResponse resp = System.Web.HttpContext.Current.Response; resp.ClearContent(); resp.StatusCode = 404; resp.AddHeader("Status", "404 Not Found"); resp.Write("<html><body><strong>The page that you requested does not exist.</strong><p><em>Visit our <a href=\"" + CmsContext.ApplicationPath + "\">home page here</a></em></p></body></html>"); resp.End(); return; // throw new System.Web.HttpException(404, "File Not Found"); //http://forums.asp.net/t/762031.aspx } }
public static void ResponsePDF(Report report, System.Web.HttpResponse response) { if (report.formatter == null) { report.Init(new PdfFormatter()); } if (report.page_Cur == null) { report.Create(); } response.ClearContent(); response.ContentType = "application/pdf"; MemoryStream ms = new MemoryStream(20000); report.formatter.Create(report, ms); ms.Close(); response.BinaryWrite(ms.GetBuffer()); response.End(); }
protected void hlnkDownload_Click(object sender, EventArgs e) { try { System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.ClearContent(); response.Clear(); response.ContentType = "text/plain"; response.AddHeader("Content-Disposition", "attachment; filename=MasterEmployeeData.xlsx;"); response.TransmitFile(Server.MapPath("~/Data/MasterEmployeeData.xlsx")); response.Flush(); response.End(); } catch (Exception ex) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Something went wrong. Check Log."; ExceptionManager.LogError(ex); } }
// zzzzzzz // http://blogs.msdn.com/b/dotnetinterop/archive/2008/06/04/dotnetzip-now-can-save-directly-to-asp-net-response-outputstream.aspx public static void ZipToHttpResponse(string DirectoryToZip) { string ReadmeText = "This is a zip file dynamically generated at " + System.DateTime.Now.ToString("G"); System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response; Response.Clear(); string fileName = @"Довнлоад.zip"; // @"Довнлоад.зип" fileName = @"Download.zip"; Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=" + fileName); //using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(Response.OutputStream)) using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(System.Text.Encoding.UTF8)) { // Add to the zip archive, the file selected in the dropdownlist. // zip.AddFile(ListOfFiles.SelectedItem.Text, "files"); // Add a boilerplate copyright file into the zip. // zip.AddFile(@"\static\Copyright.txt", ""); // The string ReadmeText becomes the content for an entry in the zip archive, with the filename "Readme.txt". // zip.AddStringAsFile(ReadmeText, "Readme.txt", ""); zip.Comment = "This will be embedded into a self-extracting exe"; zip.AddEntry("ReadMeZB.txt", ReadmeText); // http://dotnetslackers.com/articles/aspnet/Use-ASP-NET-and-DotNetZip-to-Create-and-Extract-ZIP-Files.aspx // zip.Password = "******"; // zip.Encryption = Ionic.Zip.EncryptionAlgorithm.PkzipWeak; //zip.StatusMessageTextWriter = System.Console.Out; zip.AddDirectory(DirectoryToZip); // recurses subdirectories // zip.Save(); zip.Save(Response.OutputStream); } // End Using zip Response.End(); } // End Sub ZipToHttpResponse