Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

ZipDownload

By: a guest on Aug 13th, 2013  |  syntax: C#  |  size: 0.40 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. protected void ZipDownload()
  2. {
  3.   var zip = new ZipFile(@"C:\Users\(myuser)\Desktop\desktop.zip");
  4.  
  5.   Response.Clear();
  6.   Response.AddHeader("content-disposition", "attachment;filename=docs.zip ");
  7.   Response.ContentType = "application/zip";
  8.  
  9.   using (var memoryStream = new MemoryStream())
  10.   {
  11.     zip.Save(memoryStream);
  12.     Response.BinaryWrite(memoryStream.ToArray());
  13.   }
  14.  
  15.   Response.End();
  16. }