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).

  • Maybe a few words on what ou are trying to accomplish? May 13, 2011 at 22:54
  • Done, added some elaboration.
    – James Love
    May 14, 2011 at 9:58

1 Answer 1


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

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

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.