Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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)

share|improve this answer
    
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 Nov 15 '13 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 –  Robert Lindgren Nov 15 '13 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 Nov 15 '13 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 –  Robert Lindgren Nov 15 '13 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 Nov 15 '13 at 11:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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