SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

Use the ZipSharpLib and just zip your stuff together into a new file:

share|improve this answer
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

Your Answer


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.