Results 1 to 3 of 3

Thread: [2008]Merge two .zip files?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    47

    [2008]Merge two .zip files?

    Is it possible to merge to .zip files? I know text files and mp3 files can be merged. I have searched around and some people say I need to know the binary setup of the file in order to merge it. Would it be possible to create a new file as big as the two files combined and then make a byte for byte copy of the files into the larger one?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008]Merge two .zip files?

    You wouldn't be able to do that with most file formats and certainly not with ZIP files. Most files have headers that describe the file type and various aspects of the file contents. A ZIP file is no exception. If you did what you suggest then you'd end up with a single file with two sets of headers, one of them in the wrong place and neither of them describing the file contents accurately.

    The .NET Framework has no native support for the ZIP file format. Java does have such support, so you were able to use the J# redistributable in previous versions. VS 2008 doesn't include J# though, as it has been discontinued.

    You would need to use some third-party component that does support the ZIP file format. If the component works at a high-level then it may have a function that will merge two files for you. If it works at a low level then you would have to open both files yourself. You'd then either read the entries from one file and write them to the other then delete the file you read from, or else create a new file and read the contents of each existing file and write them both to the new.

    I'm fairly certain that any high-level component would be commercial. SharpZipLib is a free, open-source component that works at a low level. Older versions didn't support writing new entries to an existing file but I think the latest version does.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: [2008]Merge two .zip files?

    Also, you can look into:

    http://www.picozip.com/

    It seems to have the functionality of merging zip files among other operations. Perhaps you can look into the libraries that they used.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width