Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top