I am creating a farm solution, I want to create zip file from 2 or more files taken from sharepoint library.

I want to temporarily save these files in my mapped folder ("Layout/MyFolder"). and allow users to download the zipped file from here.

When I try to create file by acessing path using server.mapPath(".."). It fails with error path doesnt exist.

Please help. If I should try any other approach please advice

1 Answer 1


Using Layouts for temporary storage is not really a good idea to start with (since it is shared between all sites and webs in the entire farm etc.)

Why not use the nice capabilities of a document library to save your .zip file?

It would then be a matter of creating the .zip and adding it to the document library (one basic example of that here)

  • Thanks for quick reply. I will be creating zip from a few files selected from a library. Then I want to save that zip in a folder on server from where user will be able to download the zipped file
    – mry
    Commented Nov 15, 2013 at 7:34
  • I do not see that as a good idea. Why can you not save the file to SharePoint? It will give you more functionality without having to store the file on a physical server. The approach of saving it on the server will for example be very complex if multiple web front ends is / will be used Commented Nov 15, 2013 at 7:35
  • Can you please give a sample code for the same. (I.e creating a zip from multiple files and saving it in SP?)
    – mry
    Commented Nov 15, 2013 at 8:42
  • Sample code for creating a .zip is a bit off topic. But how to upload it to SP you already have example code for in my answer Commented Nov 15, 2013 at 8:43
  • Hi Robert, I have completed the task using other approach. I am using filebytes from SPFile object and using that I am creating zip file in stream, and then saving that to another document library. Without having to save anything on server. Thanks for your comments.
    – mry
    Commented Nov 15, 2013 at 11:23

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.