none
Compress multiple files into one archive?

    Question

  • Hello everyone. I'm currently working on some backup software and it seems to be working OK, only I'd like to be able to compress the user's files into one super-massive file. Then when they want to recover the backup, I'd like to decompress this large file into all the smaller ones again.
    I understand that there are compression functions in VB.Net 2005, but how would I compress multiple files into one, and vice-versa? Any ideas?
    Wednesday, September 13, 2006 9:21 PM

Answers

  •  The .net framework does have compression classes

    System.io.Compression.

    http://msdn2.microsoft.com/en-us/library/system.io.compression.compressionmode.aspx

    The following thread has an example
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=424050&SiteID=1

    This may further help as the compression is pretty quick.

    Thursday, September 14, 2006 1:28 AM
  • The built in compression libraries do not support this directly.

    Here are 2 possible ways of dealing with this:

    1) Purchase a third party compression library. There are several vendors that supply this (including XCeed, Dart, Component One). I haven't used any of them, so I'm not sure how good / expensive they are. If you do a search for "zip control", "zip component", or "zip class" you should find links to a bunch of vendor sites. This would be the easier option.

    2) Build your functionality ontop of the .NET Compression libraries.

    This would require you to first read all the data for all the files into a single giant memory stream object, constructing an index as you go (storing a filename and a length (number of bytes)). You could then output the index, followed by the memory stream, to the compression stream. You would then implement decompression by first reading the index out of the compression stream, then loading the remainder of the compression stream into a giant memory stream and then use the index to extract each individual file out of the memory stream. This would be the more difficult option.

    -Scott Wisniewski

    Friday, September 15, 2006 2:26 AM
    Moderator

All replies

  •  The .net framework does have compression classes

    System.io.Compression.

    http://msdn2.microsoft.com/en-us/library/system.io.compression.compressionmode.aspx

    The following thread has an example
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=424050&SiteID=1

    This may further help as the compression is pretty quick.

    Thursday, September 14, 2006 1:28 AM
  • Thank you for your reply, but what I'm really looking for is a compression utility that allows archiving multiple files into one compressed file. Any ideas?
    Thursday, September 14, 2006 1:48 PM
  • The built in compression libraries do not support this directly.

    Here are 2 possible ways of dealing with this:

    1) Purchase a third party compression library. There are several vendors that supply this (including XCeed, Dart, Component One). I haven't used any of them, so I'm not sure how good / expensive they are. If you do a search for "zip control", "zip component", or "zip class" you should find links to a bunch of vendor sites. This would be the easier option.

    2) Build your functionality ontop of the .NET Compression libraries.

    This would require you to first read all the data for all the files into a single giant memory stream object, constructing an index as you go (storing a filename and a length (number of bytes)). You could then output the index, followed by the memory stream, to the compression stream. You would then implement decompression by first reading the index out of the compression stream, then loading the remainder of the compression stream into a giant memory stream and then use the index to extract each individual file out of the memory stream. This would be the more difficult option.

    -Scott Wisniewski

    Friday, September 15, 2006 2:26 AM
    Moderator
  • Thank you for your suggestion.
    Friday, September 15, 2006 4:03 PM
  •   

    Hi,
    I think “Compression and Decompression of Files using Visual Basic 2005” article on

    http://aspalliance.com/1287_Compression_and_Decompression_of_Files_using_Visual_Basic_2005.all

    may be helpful in this discussion.

    This popular white paper is written by a software engineer from our organization Mindfire Solutions (http://www.mindfiresolutions.com/).


    I hope you find it useful!

    Cheers,
    Byapti




    Monday, June 09, 2008 7:30 AM