I need to develop a C# custom webpart which allow users to download attachments from a sharepoint list. My webpart lists the attachments which the user has selected. Then, it must show him a link to download all the attachments as a zip file (similar to outlook.com feature) By doing some research (System.IO.Compression namespace), I found some ways to do it by creating a .zip file inside the server, but i have not found any way to send it to the user (and also, I would like to avoid saving the file in disk to just then send it).

PS: I`m using ApplicationPages [webmethods] and a javascript implements the user interface and call my webmethods.

Thanks !

  • Why can't you save the file in the temp folder and then use that file ? If it works for you. Dec 15, 2015 at 15:23
  • It's not the most performatic way to solve the problem I think. My front-ends would have lots of unnecessary IO since I can do it in memory stream Dec 15, 2015 at 20:52

1 Answer 1


What I would do in your situation:

  1. Create a custom action in the Files ribbon.
  2. When clicked, it redirecs the user to an application page of yours.
  3. The redirect is triggered from the custom action, e.g. from JavaScript code that also injects the Ids of current selected files in the query string.
  4. In the code of the application page, you can get the Ids from the query sring, retrieve requested documents from the doc lib, and zip them. All that being done from the OnLoad event.
  5. The application page actually does not display any UI element. Once the zip is ready as a memory stream, you send it to the Response body (with all required headers).
  6. As the page does not render any UI, the user should stay on the doc lib main page, and only get a prompt to download the file.
  • That is a good idea. I still prefer to avoid oppening a new tab, but still very nice solution for it. Thank you Jan 7, 2016 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.