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

Anyone know of a way, that within the context of server-side code (like in the callback of a WebPart) to compress a set of given files in a document library, placing the resulting compressed file back in that document library (or, even better, sending it back down to the client for them to download)?

Ideally I'd like this to run within the sandbox, so dealing with byte arrays is preferred over streams (I think, I seem to remember that the Sandbox doesn't like using System.IO.File). For this reason, I consider this to be SharePoint-specific rather than a general ASP.NET question.

Elaboration: I have code which runs from a web part which creates some XML and saves it to the document library. Ideally, I'd like this XML to be compressed into a CAB file (I can also generate the DDF if need be) and either saved into the document library, or push down to the user for them to save (or both).

share|improve this question
    
Maybe a few words on what ou are trying to accomplish? –  Anders Rask May 13 '11 at 22:54
    
Done, added some elaboration. –  James Love May 14 '11 at 9:58
add comment

1 Answer 1

up vote 2 down vote accepted

Use the ZipSharpLib and just zip your stuff together into a new file: http://icsharpcode.net/OpenSource/SharpZipLib/Default.aspx

share|improve this answer
1  
I am just not sure if this will work in Sandboxed, as it probably uses System.IO... –  Toni Frankola May 14 '11 at 20:38
    
I guess a solution can't be sandboxable yet. Closest (and only) answer. –  James Love May 24 '11 at 19:21
add comment

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.