PPPersia Posted March 9, 2010 Posted March 9, 2010 Hi Forum I want to add multiple files to a single compressed file using System.IO.Compression. And extract them back... So I found this code on MSDN which works fine, but does not support adding multiple files into 1 single compressed file. :confused: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx Any suggestion on how to do it without using 3rd party component? Thanks :) Quote
Leaders snarfblam Posted March 9, 2010 Leaders Posted March 9, 2010 That shouldn't be too tricky. There's no reason you can't just output multiple files to the same FileStream. Of course, doing it that way you won't gain any compression benefits as far as reduncancy between files, but it really shouldn't make that big of a difference. Also, this wouldn't be compatible with existing formats such as ZIP, but it doesn't sound like you will need it to be so. If you just output multiple compressed files to a single FileStream, the trick is figuring out where one starts and the next ends. You can solve this with a simple header. It can be as simple as a file count, followed by a list of entries that would each consist of the (compressed?) size and location of the sub-file within the containing file (as well as the name, if necessary, and any other info if you need it). Feel free to ask if you get stuck or have trouble getting started. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.