Guest User

ZipDownload

a guest
Aug 13th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment