(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options!
(g)Zipping files...so many options! (g)Zipping files...so many options!
(g)Zipping files...so many options!
Go Back  Xtreme Visual Basic Talk > > > (g)Zipping files...so many options!


Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2007, 06:59 AM
InfOracle InfOracle is offline
Newcomer
 
Join Date: Feb 2006
Posts: 20
Default (g)Zipping files...so many options!


I have a question regarding zipping (or gzipping for that matter). I've figured that there's (at least) 3 similar ways to zip files:
Using the java.util.zip class (and its associates)
Using the csharpziplib class (with the wrapper class)
Using the system.io.compression class

However, I haven't found a single VB code to add multiple files to an existing zip file. Everytime I add a new file, the previous file gets deleted! This is how I have it setup now. I don't want to use the zipfolder because there are contents in it that I don't want to get zipped. Does anybody have any ideas? Thank you in advance!

Code:
Imports System.IO
Imports NetFrameworkWrappers
    Public Function ZipFile(ByVal sFilePath As String, ByVal sFile As String, ByVal _
     sZipFile As String, ByVal bNew As Boolean) As Boolean
        Dim fzw As New FileZipWrapper
        If bNew = False Then
            fzw.ZipFile(sFilePath & sFile, sZipFile)
        Else
            Stop
            fzw.ZipFile(sFilePath & sFile, sZipFile)

        End If
        ZipFile = True
        '        fzw.UnzipFile(zipFileName, unzipFileName)

        'Dim sr1 As New StreamReader("..\tozip.txt")
        'Dim sr2 As New StreamReader(unzipFileName)

        'Dim results As Boolean = sr1.ReadToEnd() = sr2.ReadToEnd()
        'sr1.Close()
        'sr2.Close()

        'Return results
    End Function

    Public Function ZipFolder(ByVal sFilePath As String, ByVal sZipFile _
     As String) As Boolean
        Dim fzw As New FileZipWrapper
        fzw.ZipFolder(Path.GetFullPath(sFilePath), Path.GetFullPath(sZipFile))

        Dim fi As New FileInfo(Path.GetFullPath("..\ZipTest\ToZip.zip"))
        Return fi.Length = 55864
    End Function

Last edited by InfOracle; 03-22-2007 at 07:05 AM.
Reply With Quote
  #2  
Old 04-16-2007, 07:08 PM
PrOpHeT's Avatar
PrOpHeT(g)Zipping files...so many options! PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

the io.compression class does not manipulate .zip files directly instead it compresses using the gzip algorithm. Zip files are a structure of compressed data. Picture it like a database, that contains all the data of the file(s) such as folder structure, filenames, etc... then the database is compressed.

A good place to start would be here http://www.gzip.org/

now if you do not need the files to be compatible with other zip programs, but just want to to contain multiple files in a compressed format, may I suggest that you create a structure containing all the relevant information for each file and add them to an array list, then serialize and compress the array list. You could use a data table as well. There are many ways to store the information. If there are going to be many larger files that do not lend themselves to in memory decompression as a whole, I suggest serializing and compressing each individually and then combining the files into a larger binary file. keep a record of the offset for each file and append it to the end of the binary. that way you can parse the binary data out and deflate the files one by or in separate threads.

I hope this was more informative than confusing, I just wanted to let you know there were many sides to this coin.
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options! (g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options! (g)Zipping files...so many options!
(g)Zipping files...so many options!
(g)Zipping files...so many options!
 
(g)Zipping files...so many options!
(g)Zipping files...so many options!
 
-->