Page 1 of 3 123 LastLast
Results 1 to 40 of 82

Thread: ZIP Compression Using Pure Visual Basic

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    ZIP Compression Using Pure Visual Basic

    Does anyone have any kind of module, class module, etc. that can compress files using ZIP compression?

  2. #2
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: ZIP Compression Using Pure Visual Basic

    vbAccelerator.com has a freeware zip library; though I don't believe it's been written in VB6...
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  3. #3

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    I already know about those. I'm trying to find a module, class module, etc. for it. I don't like using dlls and ocxs.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Not much help here, very likely you just have to code it by yourself.

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ZIP Compression Using Pure Visual Basic

    VB isn't capable of doing such stuff on its own - you must use some library and the one from vbAccelerator comes very handy (also full source is available). So, if you don't like it then you pretty much on your own.

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RhinoBull
    VB isn't capable of doing such stuff on its own - you must use some library and the one from vbAccelerator comes very handy (also full source is available). So, if you don't like it then you pretty much on your own.
    Err... don't push out such lies so easily. VB can do it very well (like about any other programming language out there), nobody just haven't bothered to do it since there are already-made solutions available.

    inventrex: the easiest solution is just to use external DLL. Can't really rely that a user has Windows XP or WinZip (I use IZarc and have disabled WinXP's own ZIP functionality in my other computer).

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by Merri
    Err... don't push out such lies so easily. VB can do it very well (like about any other programming language out there), nobody just haven't bothered to do it since there are already-made solutions available. ...
    I don't really like, Merri, the way you express yourself so next time watch it.
    Anyway, there were plenty of attempts in VB but non of them succeeded - whould that mean anything to you at all ???

  9. #9
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    I don't like your way either so we're equal on that. On the topic: it just means not everyone have the skills to do it; ZIP format is pretty feature rich as it is. ZIP File Format Specification has a lot of text in it.

  10. #10

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    If there is none, can someone please give me the function for the best compression that you know of?

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Here is the full link to the zip page on vbAccelerator.

    IMO, you could write it yourself in VB fairly straightforwardly, all you need to do is learn the algorithm (compression method) and just code that.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    I already tried that but I don't know like using dlls or ocxs. I'm just a beginner, so I need to see as much code examples as possible.

  14. #14
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    DLLs are good, they reduce the amount of code you have to write yourself... If you're just a beginner you should learn how to use DLLs and OCXs instead of just ignoring them. Trust me, eventually you won't be able to work without them, so better to start using them earlier

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    400

    Re: ZIP Compression Using Pure Visual Basic

    It just doesn't seem right using dlls and ocx created using C++ in a Visual Basic project. I'm sure that Visual Basic can do as much as C++ can, but no one wants to give away any of their source codes.

  16. #16
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: ZIP Compression Using Pure Visual Basic

    Well, if you find any. I believe Rhino when he says that people have tried and failed, although I'm more inclined to believe they gave up

    As I said, you could do it yourself. There isn't source code for everything.

    And BTW, VB can do pretty much as much as C++, but the more you get out of the VB "comfort zone" and into more advanced topics, the more roundabout and fiddly code you are gonna need.

  17. #17
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: ZIP Compression Using Pure Visual Basic

    Well I not seen any code as yet that can Create Zip files from VB Code. Tho I did once find an Opensource VB Program that allows you to extract from Zip files, but that not you want is it.

    I did come accross this tho
    Deflate64/Inflate64 for coders

    http://www.pscode.com/vb/scripts/Sho...58473&lngWId=1
    there also some other good compression stuff on the site as well.
    When your dreams come true.
    On error resume pulling hair out.

  18. #18
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    there also some other good compression stuff on the site as well.
    Yes, like:
    http://www.pscode.com/vb/scripts/Sho...53174&lngWId=1

    /edit:
    BTW, where does all this "VB can't do this, use C!!" stuff come from?
    The only things VB can't do is drivers, safe multi threading (at least as standard EXE) and direct low level IO.
    And creating ZIP files is far away from being low level ;-)
    Last edited by rm_03; Aug 21st, 2005 at 11:06 AM.

  19. #19
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ZIP Compression Using Pure Visual Basic

    I understand I flamed this thread abit, HOWEVER I will be proven wrong ONLY if someone shows me a really working example of "creating zip file using pure any pre dot net vb" and it has to perform just like Winzip, RAR, PKZip and/or some others do - it could better but not lousy. Until then it's all going to be speculations. Sorry.

  20. #20
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by rm_03
    BTW, where does all this "VB can't do this, use C!!" stuff come from?
    It comes from the 90's when C++ got a lot of fanboys and they bashed VB all they could. Atleast, that is one of the main reasons.

    Rhino: what you're trying to say is that VB couldn't handle reading and writing a file. A ZIP is a file, thus is made of bits. You can handle bits with VB (And, Or, Xor, bitshifting with some trick code). Reading and writing a ZIP file is just converting data from a format to another.

    You can find a JPEG compressor over at PSC, which saves JPG files. Also, I've made a MIX file reader and writer using VB: MIX files are from Command & Conquer, which is a archive format without actual compression by the file format itself as the contents that were stored were already compressed; which is very much like ZIP. ZIP compresses individual files and acts otherwise as an archive. Too bad I lost the source for that when my harddisk failed a few years ago... not that C&C or Red Alert would be interesting these days.

    I have also made a Settlers II map reader and writer which contains multiple map data for a single map... quite similar to archive file, though lacks details for filenames. For Transport Tycoon I have a reader for GFX files (contains multiple compressed graphics files), though I never got as far as writing the code for saving a file. I could have.

    These should be enough to proof ZIP file reading and saving can be done with VB. WinZip, PKzip and the like use ASM optimized code, so you just can't beat them with higher level languages no matter what you do. You could make the speed quite good though.

  21. #21
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by Merri
    ... A ZIP is a file, thus is made of bits. You can handle bits with VB (And, Or, Xor, bitshifting with some trick code). ...
    That's correct.

    Quote Originally Posted by Merri
    ... Reading and writing a ZIP file is just converting data from a format to another. ...
    That's where the problem resides.

  22. #22
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Right. Believe it as you wish, for the sake of having a differing opinion. I haven't seen anything that proves against. "That's where the problem resides" doesn't really tell why there would be a problem or why VB couldn't do it.

    Enjoy your "I won!" dance, won't comment on this any more.


    The Proof: "This code can be used to create filetypes wich used Deflate as compression algo (ZIP,GZIP,CAB, etc.etc)" (mentioned earlier in this very thread)


    Edit Fixed typo.
    Last edited by Merri; Aug 21st, 2005 at 02:43 PM.

  23. #23

  24. #24
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Re: ZIP Compression Using Pure Visual Basic

    Reply to abazabam,
    Hello abazabam,
    You can try winzip Comand line

    download this 2 files from http://www.winzip.com/downcl.htm

    1)WinZip 9.0
    2)Command Line Support Add-On 1.1 SR-1

    than read the documentation about Command Line Support Add-On 1.1 SR-1

    i wrote a VB code using a batch file:

    VB Code:
    1. Call Shell("C:\myBatch.bat", vbMaximizedFocus)

    inside myBatch i used the wwzip command:
    Code:
    C:\wzzip C:\myZip.zip C:\*.pdf
    All the pdf file will be zip to one zip file called myZip.zip

    Best Regards,
    ERAN
    Eran Fox
    ASSEMBLER,C,C++,VB6,SQL...

  25. #25
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RhinoBull
    I would enjoy it more if someone proves me wrong, though.
    I hope you will enjoy this

    1) Download the project from the link I posted.
    2) Open cls_Zip.cls.
    3) Add the following type:
    Code:
    Private Type Pack_Helper_Type
        valid   As Long
        CRC32   As Long
        USize   As Long
        CSize   As Long
        offset  As Long
    End Type
    4) Overwrite the "pack" function with the following:
    Code:
    Public Function Pack(ZipName As String, files() As String, CompLevel As Integer) As Integer
        Dim CentDat         As Central_Header_Type
        Dim helpers()       As Pack_Helper_Type
        Dim EndCentralSig   As End_Header_Type
    
        Dim fhIN        As Integer, fhOUT       As Integer
        Dim i           As Integer
    
        Dim lngSig      As Long, lngCenOff      As Long
    
        ReDim helpers(LBound(files) To UBound(files))
    
        fhOUT = FreeFile
        Open ZipName For Binary As #fhOUT
    
        For i = LBound(files) To UBound(files)
            If Not Trim$(files(i)) = vbNullString Then
                helpers(i) = AppCompFile(fhOUT, files(i), CompLevel)
            End If
        Next
    
        lngSig = &H2014B50
        lngCenOff = Seek(fhOUT) - 1
    
        For i = LBound(helpers) To UBound(helpers)
            With CentDat
                .CRC32 = helpers(i).CRC32
                .CSize = helpers(i).CSize
                .offset = helpers(i).offset
                .USize = helpers(i).USize
                .LenFname = Len(GetFile(files(i)))
                .Method = CompLevel
                .VerExt = 20
                .VerMade = 20
            End With
            Put #fhOUT, , lngSig
            Put #fhOUT, , CentDat
            Put #fhOUT, , CStr(GetFile(files(i)))
        Next
    
        lngSig = &H6054B50
    
        With EndCentralSig
            .signature = lngSig
            .Entries = UBound(files) - LBound(files) + 1
            .TotEntr = .Entries
            .CenOff = lngCenOff
            .CenSize = Seek(fhOUT) - 1 - lngCenOff
        End With
    
        Put #fhOUT, , EndCentralSig
    
        Close #fhOUT
    
    End Function
    
    Private Function AppCompFile(ByVal fh As Integer, ByVal file As String, ByVal level As Integer) As Pack_Helper_Type
    
        'On Error GoTo OnError
    
        Dim LocDat                As Local_Header_Type
    
        Dim fhIN                  As Integer
        Dim btFile()              As Byte
    
        Dim lngSig                As Long
    
        AppCompFile.offset = Seek(fh) - 1
    
        fhIN = FreeFile
        Open file For Binary As #fhIN
            ReDim btFile(LOF(fhIN) - 1) As Byte
            Get #fhIN, , btFile
        Close #fhIN
    
        LocDat.USize = UBound(btFile) + 1
        LocDat.CRC32 = CRC.CalcCRC32File(btFile)
    
        Deflate btFile, level, False
    
        With LocDat
            .CSize = UBound(btFile) + 1
            .LenFname = Len(GetFile(file))
            .Method = level
            .VerExt = 20
        End With
    
        lngSig = &H4034B50
    
        Put #fh, , lngSig
        Put #fh, , LocDat
        Put #fh, , CStr(GetFile(file))
        Put #fh, , btFile
    
        With AppCompFile
            .CRC32 = LocDat.CRC32
            .CSize = LocDat.CSize
            .USize = LocDat.USize
            .valid = 1
        End With
    
    OnError:
    
    End Function
    
    Private Function GetFile(file As String) As String
        GetFile = Mid$(file, InStrRev(file, "\") + 1)
    End Function
    Example on how to use this function:
    Code:
    Option Explicit
    
    Dim p   As New cls_Zip
    
    Private Sub Form_Load()
        Dim files(0)    As String
        files(0) = "C:\export.def"
        p.Pack "C:\new.zip", files, 8
    End Sub
    I've done this in about 1 1/2 hours, so you can only add files to the root.
    You want a feature, add it.

    /edit: Oups, I forgot, you have to add the Deflate module from DreamVB`s link.
    Last edited by rm_03; Aug 21st, 2005 at 03:44 PM.

  26. #26

  27. #27
    Lively Member rm_03's Avatar
    Join Date
    Aug 2004
    Posts
    92

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RhinoBull
    That proves nothing more than the fact that you can create files in VB.
    I don't get it...

    1) The question was: code to compress a file with ZIP compression
    2) You said: Can't be done in VB.
    3) dreamvb posted a link to modules that show the Deflate/Inflate algorithms used in Zip files. Disproof of your statement.
    4) You said you want a working example on how to create a Zip file with VB classic.
    What you said with this is: You don't believe VB has arithmetic operators and can do file IO. The converse was proved just when VB was released some years ago.
    5) I posted a working example on how to create the Zip file structure with compressed data in it.
    6) You said: "This only proofs VB can do file IO".

    Right... If VB creates a ZIP file, it's file IO.
    If WinZip creates a ZIP file, it's a ZIP file.

    This is ridiculous...

  28. #28
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Reading this thread reminded me of all the people saying VB didn't support pointers...
    Anyway; I agree with RM_03, VB can do pure File IO/Compression/Decompression without a problem it's just that no one actually thought about doing it due to the freeware/open source libraries available (ZLib, etc).

    Yeah, I also dislike using external files.
    MSVBVM60.DLL or MSVBVM50.DLL ring a bell? - In other words you'll always be depending on external files to run your projects. One more or less doesn't really make a difference

  29. #29
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: ZIP Compression Using Pure Visual Basic

    I hope this helps.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  30. #30
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: ZIP Compression Using Pure Visual Basic

    Come on guys, don't fight because of some bytes and bits!
    Share your knowledge!

  31. #31
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by Devion
    MSVBVM60.DLL or MSVBVM50.DLL ring a bell? - In other words you'll always be depending on external files to run your projects. One more or less doesn't really make a difference
    Technically, 1 less would make a difference

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  32. #32
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ZIP Compression Using Pure Visual Basic

    this is childish ,silly and stubborn
    That's a qoute of from neg rep comments someone (probably rm_03 - sorry if not) gave me for my post in this thread (last prior to this) so it is silly to rep for an opinion. BTW, I don't really give a damn thing about it.

    Anyway, that sample really proves nothing but what I previously said: there were plenty of attempts but non of them performed like Winzip, RAR or say PKZip and that's what matters. I did say that VB "isn't capable" so maybe I should've had said "lousy performer" in this regards instead, well ... perhaps ...
    Also, as Merri pinted out Winzip, RAR and others use "ASM optimized code" so there is no way to beat that performance and it's a most important thing: who's going to use your pure VB compressor if it takes 30 min when it may 30 sec ... And you call that "childish ,silly and stubborn"? Stubborn maybe, but certainly not childish and/or silly.

    My best regards - especially to the person who neg rep me.

  33. #33
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    What he means is, the code doesn't answer the question. I don't know why many of you are finding it so hard to understand.

    RhinoBull said what he said, because the code given doesn't prove the original argument; that VB can write ZIP compression in PURE VB.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  34. #34
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Getting a neg rep from this.. mmh.. I'll refrain from saying something stupid

    Anyway; VB can use asm optimized code also so that wouldn't be a issue. If we are going for a really pure without any api's etc version of a unzipper/zipper mmh.. it would be slow on large files but it's still doable

  35. #35
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    I'd like to see someone attempt this, then I could try and port it to ASM

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  36. #36
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    I'll take the challenge :-)

  37. #37
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: ZIP Compression Using Pure Visual Basic

    inventrex: Have you looked at the traffic on your ports while using MSN Plus!? I have a post somewhere else which says MSN Plus, while running, sends POST (?) requests to websites which the MSN Plus creator gets paid for having visitors. You know those online things that say you get $0.50 for every person who visits this site using the link we give you? He did that. netstat -a if I remember correctly. Technically, he is being paid for the thousands of people who are using his program. Personally, I would like a massive banner across the program saying this is happening, before using an "illegal" add-on like that.

    (PS: Saw the Petition in your sig)

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  38. #38
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by RhinoBull
    Also, as Merri pinted out Winzip, RAR and others use "ASM optimized code" so there is no way to beat that performance and it's a most important thing: who's going to use your pure VB compressor if it takes 30 min when it may 30 sec
    Maybe more like 40 - 60 seconds than 30 minutes (thus somewhat identical to pure C/C++ implementation). With proper optimizations you can do "miracles". A lot of ZIP compression is just low level math which can be done real fast no matter what the language. With ASM you can just get much more control over it as there are more specific commands one can use... it just takes darn long to write it all in ASM.

  39. #39
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: ZIP Compression Using Pure Visual Basic

    Quote Originally Posted by Merri
    Maybe more like 40 - 60 seconds than 30 minutes (thus somewhat identical to pure C/C++ implementation). With proper optimizations you can do "miracles". A lot of ZIP compression is just low level math which can be done real fast no matter what the language. With ASM you can just get much more control over it as there are more specific commands one can use... it just takes darn long to write it all in ASM.
    The time you are busy making it in asm you get back by the fast computations done

  40. #40
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: ZIP Compression Using Pure Visual Basic

    Yeah, but the thing is... that wasn't my point. It is already done in ASM. Just go grab Info-ZIP source code and you can use it inline in any compiler that supports inline ASM (afaik). VB6 is of course out of the list, though you can still use the ASM optimized DLL. That is if you want ASM optimized. VB6 optimized would be good enough for many cases, the only time one has a special need for the most extreme speed is when you compress a lot of files (thousands) or if you compress very big files. And even then it might be the computer harddisk which cause the most slowdown, knowing the processing power of a modern computer.

Page 1 of 3 123 LastLast

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