Page 1 of 2 12 LastLast
Results 1 to 40 of 49

Thread: zip and unzip

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60

    zip and unzip

    i want to zip and unzip files and folder trough vb but i dont know how to begin, i found that there is a dll called zipfldr but i've found nothing in the forum, if anyone know the syntax i will appreciate your help...

  2. #2
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    vbAccelerator has a freeware ZIP library, example included. Alternativaly, you can require your user to install WinZip and use the app via the command line.
    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

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    i mean without that, only a syntax that automates the process like:

    zip ("folder","password") to "destiny folder\file.zip"
    unzip ("file.zip","password") to "destiny folder"

    im looking for a thing like that

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    http://www.mvps.org/emorcillo/vb6/shell/xpzip.shtml

    only in xp though.

    You'd also need the OLELIB.tlb , which is also there. There shouldn't be any dependencies for this as long as the person is using xp.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    ok...can you give an example to unzip a file with this?

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Hmm.... I guess not .

    I thought it would include an example, but it didn't. And I couldn't figure it out. Oh well. There isn't really another resource.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    me neigther ... i dont understand it and i dont have any idea on how to understand it...

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    I thought that XP handled .zip files automatically
    Not sure how to make them with it though. I use WinZip, so it opens for everything anyways.

  9. #9
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Here's what you need to do to use the class from mvps.org..

    Extract olelib.tlb and olelib.odl from tl_ole.zip and copy them to your Windows\System32 directory.

    Open a command window and navigate to Windows\System32,
    eg cd\windows\system32

    Register the two files as follows:
    Type: regtlib olelib.tlb and press <enter>
    Type: regtlib -o olelib.odl and press <enter>

    In VB6, start a new project and add a reference to:
    Edanmo's OLE interfaces & functions v1.81

    Add the CompressedFolder.cls to your project

    To create & add files to a zip:
    VB Code:
    1. Dim z As CompressedFolder
    2. Set z = New CompressedFolder
    3.    
    4. z.CreateZip "c:\temp\somefile.zip"        ' Create an empty zip file
    5. z.CompressFile "c:\temp\filetozip.txt"    ' Add a file to the zip
    To extract files from a zip:
    VB Code:
    1. Dim z As CompressedFolder
    2. Set z = New CompressedFolder
    3.  
    4. z.OpenZip "c:\temp\somefile.zip"           ' Open the zip file
    5. z.ExtractFile "zippedfile.txt", "c:\temp"   ' Extract the file to c:\temp
    6.    
    7. Set z = Nothing
    Hope that helps
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  10. #10
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    What happens with vbaccelerator's suggestion. You can use Winzip to zip/unzip files using command line.... but you'd need the (registered version of) Winzip installed and the command-line add-in as well. Otherwise... the code won't work.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  11. #11

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    ok i kinda works...but it give me some errors while extracting files and making the zips..

  12. #12

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    and before anything....i couln't register the olelib.tlb and olelib.odl because i dont have the regtlib.exe file ...but i added the reference by searching it...can that be the problem?

  13. #13
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    REGTLIB.EXE should be in your Windows directory. I'm using WinXP Pro SP1a. Adding a reference to olelib.tlb in VB (as you did) will also register the file, so that should be OK. But the ODL file also needs to be registered for the whole thing to work properly. I'd say that's why you're still getting errors.

    If you can't find REGTLIB.EXE, I could probably email it to you. I guess it's just a standard OS file.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  14. #14

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    ok ill appreciate if you send me the file its only the regtlib.exe wich i need or do i need another file to run the regtlib?

  15. #15
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    I doubt that you really don't have the file...
    Attached Files Attached Files
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  16. #16

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    tanx for the file ... and im sure i didnt have it...but that doesnt matter know....i've registered the 3 files olelib.tlb olelb.odl and olelib2.tlb using start menu, run, regtlib "file" ...

  17. #17

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    still giving error...
    i add the compress folder class module and i wrote this code in a command button, this is the code:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim z As CompressedFolder
    3. Set z = New CompressedFolder
    4.    
    5. z.CreateZip "c:\file.zip"        ' Create an empty zip file
    6. z.CompressFile "c:\file.txt"    ' Add a file to the zip
    7. End Sub
    the errors ocurs in this line:
    VB Code:
    1. ' Get the parent folder IDL
    2.    oDesktop.ParseDisplayName 0, 0, StrPtr(sFolder), lPtr, lPidl, 0
    i created the txt file so that isn't the problem...

  18. #18
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    It appears that problems occur when you zip & unzip files in the root directory, ie C:\

    Try again but use a different directory, eg c:\temp
    I don't know why this happens
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  19. #19

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    that was the problem...now it works....thank you all for your time specially you pnish and buggy programmer you took pretty much time on this....i guess thats all

  20. #20

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    one last question....how do i extract the files if theres a password in the zip...cause if the txt file inside the zip has a password it just extract the file in blank i mean empty...

  21. #21
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Glad to see you've got it working.

    Good luck
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  22. #22
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Originally posted by Undotgiven
    one last question....how do i extract the files if theres a password in the zip...cause if the txt file inside the zip has a password it just extract the file in blank i mean empty...
    I'm not sure. Give me a few minutes and I'll see if I can figure it out.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  23. #23
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    Hmmmm. Got me stumped I'm afraid

    You can query the zip to see if it has a password:
    MsgBox z.GetFileInfo("fileinzip.txt", HasAPassword)

    and you can set a password on a zip:
    z.ShowAddPassword

    But I can't see how you can specify a password when trying to extract a password protected file.

    Sorry I can't help you. Maybe you could try getting in touch with the author: [email protected]

    Good luck
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  24. #24
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    I have actually emailed that person before on something different, but he has never replied, so I wouldn't wait for the reply.

    Maybe the password dialog shows if you extract the files. Try to extract a password protected zip file and see what happens.

    I'd also try this:
    VB Code:
    1. Public Sub RemovePassword()
    2. Dim oCtxMenu As IContextMenu
    3. Dim tICI As CMINVOKECOMMANDINFO
    4.  
    5.    Set oCtxMenu = getContextMenu
    6.    
    7.    tICI.cbSize = Len(tICI)
    8.    tICI.lpVerb = [b]2[/b] 'The add password was '1'.  I changed it to '2'.  Try it with 3,4 etc.
    9.    oCtxMenu.InvokeCommand tICI
    10.    
    11. End Sub
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  25. #25

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    ok it work only with 0,1 and 2 i've tested a lot of numbers but it only works with those i even tried negative numbers... but vb crashes ... and when i use that it doesnt unzip any files its just like entering the correct password and thats all it doesnt do anything else...

  26. #26

    Thread Starter
    Member
    Join Date
    Jan 2004
    Posts
    60
    somebody there? plz help!....

  27. #27
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    I found this on the vbAccelerator web site. I don't know if this is the same prog that TheVader & Mc Brain were talking about, but it appears to work OK (and I don't have WinZip on my PC).

    Give it a go and see what you reckon

    Without looking too closely, that file I posted appears to only ZIP files, not UNZIP.

    Checkout this site, it looks promising: http://www.info-zip.org/
    Attached Files Attached Files
    Last edited by pnish; Aug 11th, 2004 at 12:23 AM.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  28. #28
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    This is where the info-zip site eventually leads:

    http://www.gzip.org/zlib/
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  29. #29
    New Member
    Join Date
    Aug 2004
    Location
    Melbourne, AU
    Posts
    2

    What about just reading the contents?

    Looks like you guys have zipping and unzipping down. But what if I just want to read the contents of the zip file and display the file names or store the file names in a database?
    Chad
    The Edge On-Line
    www.theedgeradio.com

  30. #30
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    I believe the software from mvps.org can do this.

    Here's the link again....

    http://www.mvps.org/emorcillo/vb6/shell/xpzip.shtml
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  31. #31
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,179

    Re: zip and unzip

    You can try this new project which has no external DLL dependancies -- https://github.com/wqweto/ZipArchive

    This is a single-class pure VB6 library for zip archives management with ASM speed (uses bytecode thunks) that supports the original ZipCrypto and the stronger AES encryption for password protected archives.

    cheers,
    </wqw>

  32. #32
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    536

    Re: zip and unzip

    Quote Originally Posted by wqweto View Post
    You can try this new project which has no external DLL dependancies -- https://github.com/wqweto/ZipArchive

    This is a single-class pure VB6 library for zip archives management with ASM speed (uses bytecode thunks) that supports the original ZipCrypto and the stronger AES encryption for password protected archives.
    VERY interesting.
    I tried the vbZip project, and it works flawless.
    Like this:
    Code:
    vbzip -o "T:\ZIPTEST" x "T:\Desktop\bla.zip"
    When I want to use your work in my projects, I only need to unzip a zip file to a folder.
    I tried the basic project.

    Code:
    Private Sub Command4_Click()
        Dim dblTimer        As Double
        Dim bResult         As Boolean
        Dim sLastError      As String
    
        dblTimer = Timer
        Set m_oZip = New cZipArchive
        m_bCancel = False
        With m_oZip
            .OpenArchive "T:\Desktop\bla.zip"
            Set m_oExtractInMemory = m_oZip
            bResult = .Extract("T:\ZIPTEST")
            Set m_oExtractInMemory = Nothing
            sLastError = .LastError
        End With
        Set m_oZip = Nothing
        labProgress.Caption = IIf(bResult, "Done. ", sLastError & ". ") & Format(Timer - dblTimer, "0.000") & " elapsed"
    End Sub
    This doesn't create the folder to extract to.
    And even when the folder exists, no extracted file comes in.
    I thought the .Extract method would do this.

    Can you give me a hint please?

    Karl

  33. #33
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,179

    Re: zip and unzip

    @Karl77: I'm sorry for the confusing sample you found but you don't need the lines that set m_oExtractInMemory to make it work. This particular sample shows how to intercept BeforeExtract event and (selectively) re-route target file of extraction to a memory stream, that's why there is nothing extracted on disk.

    You can check out the samples in README in the repos home-page/root for a quick intro to class usage, for instance this simple one extracts all zipped files to a folder on disk:

    thinBasic Code:
    1. With New cZipArchive
    2.     .OpenArchive "test.zip"
    3.     .Extract "extract_folder"
    4. End With
    cheers,
    </wqw>

  34. #34
    Addicted Member Wolfgang Enzinger's Avatar
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    160

    Re: zip and unzip

    Quote Originally Posted by wqweto View Post
    You can try this new project which has no external DLL dependancies -- https://github.com/wqweto/ZipArchive

    This is a single-class pure VB6 library for zip archives management with ASM speed (uses bytecode thunks) that supports the original ZipCrypto and the stronger AES encryption for password protected archives.
    Thank you! This is really an impressing piece of code!

    However, it uses techniques which obviously make some AV vendors' alarm bells ring ... see this VirusTotal result with a test program I made.

    So for now I had to switch back to Edanmo's CompressedFolder.cls. Nevertheless I'm busy now sending emails to those AV vendors asking for investigation of the issue. Let's see what happens ...

    Wolfgang

  35. #35
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,179

    Re: zip and unzip

    Too bad as I don't have any false positives when the class is part of a larger project.

    I'll probably need to obfuscate it further to fool the AV vendors for 100% fool-proof solution. Something like bare LoadLibrary+GetProcAddress approach :-))

    cheers,
    </wqw>

  36. #36
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,179

    Re: zip and unzip

    @Wolfgang Enzinger: Btw, just tested vbzip.exe (the command-line zip utility from projects test directory) and only machine-learning engines raise alerts on VirusTotal. Removing the call to VirtualAlloc reduced these to only one ML engine so (most probably) using the class is pretty safe in the wild.

    Now, why your project raises so much false alarms is another topic but my point is that you might have troubles w/ AVs whichever zip impl is used, might be getting false alarms for totally unrelated to zip archives management reasons.

    cheers,
    </wqw>

  37. #37
    Addicted Member Wolfgang Enzinger's Avatar
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    160

    Re: zip and unzip

    Quote Originally Posted by wqweto View Post
    Now, why your project raises so much false alarms is another topic but my point is that you might have troubles w/ AVs whichever zip impl is used, might be getting false alarms for totally unrelated to zip archives management reasons.
    That, or a combination of some things. My project is a console application using Karl E. Peterson's MConsole. That alone usually doesn't trigger any false alarms, but maybe in combination with other techniques it does, who knows.

    Anyway, Avira meanwhile confirmed that this is a false positive.

    Wolfgang
    Last edited by Wolfgang Enzinger; May 1st, 2019 at 09:48 AM.

  38. #38
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: zip and unzip

    Quote Originally Posted by Wolfgang Enzinger View Post
    So for now I had to switch back to Edanmo's CompressedFolder.cls.
    Since you're using the RC5, perhaps the "zipfile" virtual table binding would be another alternative for you...?
    SQL = "Select * From zipfile('" & FileNameOnDisk & "')"

    At work, we use (and "ship") it already (since a year or so), to deal with Office-Documents (*.xlsx, *.docx)
    (for "user-template-based reporting").

    Olaf

  39. #39
    Addicted Member Wolfgang Enzinger's Avatar
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    160

    Re: zip and unzip

    Quote Originally Posted by Schmidt View Post
    Since you're using the RC5, perhaps the "zipfile" virtual table binding would be another alternative for you...?
    Cool! Until now I was unaware that The SQLite Zipfile Module is already compiled into RC5.

    Well, for this specific program I'll stay with Edanmo's CompressedFolder.cls because ... this is kind of an "admin tool", and those admins love to copy the EXEcutable file only to any folder and then complain that it doesn't work ... so this tool should have zero dependencies. But for other projects this will come in handy.

    Wolfgang

  40. #40
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    505

    Re: zip and unzip

    wqweto will your class run in a separate thread ?

    I am currently using shell to zip and unzip

    WP

Page 1 of 2 12 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