Zipping Folders
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: Zipping Folders

  1. #1
    Join Date
    May 2004
    Posts
    42

    Zipping Folders

    I am in need to zip folders using a VB6 app. I have the folders created but
    I need to compress them into a zip file programically. Does anyone have any ideas on how to do this??

    Thanks in advance for your help

    Nate

  2. #2
    Join Date
    May 2005
    Location
    Sterling Heights, MI
    Posts
    74

    Re: Zipping Folders

    A search of CodeGuru would have turned up this gem.

    How To Zip And Unzip In VB

    Got a question on Linux? Visit our Linux sister site.
    Why Bound Controls Are Evil
    IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects!
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3
    Join Date
    May 2004
    Posts
    42

    Re: Zipping Folders

    Thanks I should of searched first. I saw this a couple of min before you replied. Thanks again.

  4. #4
    Join Date
    May 2004
    Posts
    42

    Re: Zipping Folders

    This is a follow up to my early post. I am still having problems zipping folders. I can zip all files in a given dir but can not get sub folders to be included in the zip. Does anyone know what I am missing? Here is my code:

    Dim oZip As CGZipFiles '

    Set oZip = New CGZipFiles

    oZip.ZipFileName = "C:\Temp\Request\MyZip.Zip"
    oZip.AddFile "C:\Temp\Request\PR006454\*.*"


    If oZip.MakeZipFile <> 0 Then
    MsgBox oZip.GetLastMessage
    End If

    Set oZip = Nothing

  5. #5
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,537

    Re: Zipping Folders

    Quote Originally Posted by Nate Hunter
    This is a follow up to my early post. I am still having problems zipping folders. I can zip all files in a given dir but can not get sub folders to be included in the zip. Does anyone know what I am missing? Here is my code:

    Dim oZip As CGZipFiles '

    Set oZip = New CGZipFiles

    'oZip.ZipFileName = "C:\Temp\Request\MyZip.Zip"
    'oZip.AddFile "C:\Temp\Request\PR006454\*.*"

    oZip.RecurseFolders = True
    oZip.RootDirectory = "C:\Temp\Request\PR006454"
    oZip.AddFile "*.*"


    If oZip.MakeZipFile <> 0 Then
    MsgBox oZip.GetLastMessage
    End If

    Set oZip = Nothing
    This should work when reading the notes in the documentation 'How to Zip and Unzip in VB'
    ( I have got it working if the directory is the App.path but still problems if oZip.RootDirectory isn't App.path )

    Jonny Poet
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  6. #6
    Join Date
    May 2004
    Posts
    42

    Re: Zipping Folders

    thanks for the reply. You are right I can get the code posted previously to work with the App.path. I can use this but I would like to remove the app from the zip. I tried:

    oZip.RemoveFile "Project1.exe"

    with no luck. any Ideas how I can get this file out of my zip file.

    Thanks again.

  7. #7
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,537

    Re: Zipping Folders

    Quote Originally Posted by Nate Hunter
    ...to work with the App.path.
    I'm frightened in between, that there are bugs in the dlls. Does anyone have or know where to get the original dlls for debug ? In the different notes regarding that articel you see exactly this problems coming up:
    1) You Cannot delete.
    2) If its given fullpath in oZip.AddFile fullpathstring then you cannot
    add subdirectories to even when you set oZip.RecurseFolders = True
    You have to use: oZip.RootDirectory in this case. But if doing so then
    3) you didnt get zipped the folder you want, app.path files are zipped !

    So the solution is : Lets get the dlls source and repair it. That should work, isn't it ?
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  8. #8
    Join Date
    Nov 2008
    Posts
    1

    Angry Re: Zipping Folders

    I had the same what an application I'm making. It is indeed not possible to zip the contents of another folder than the app.path folder. This is a bug, I presume?
    The .RecurseFolders = True is working, but useless when only the application folder, including its subfolders, is zipped.

    Please anuone who can repair this.

    BTW, should the ZIP 3.0 beta do it better?

    Regards,
    Jaap

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,724

    Re: Zipping Folders

    As far as I know, the CGZip and CGUnzip classes base on the dlls Zip32.dll and Unzip32.dll

    Personally I have used Unzip32.dll but had written an own wrapper function 'cause I didn't need all that class overhead. I found the dll itself working without errors.

    Since you can get the source of the wrapper classes, you should study this and determine if the errors are produced in the VB-class or if they reside in the dll Zip32.dll itself. The function Zip32.dll provides may seem a little complicated but perhaps it behaves alright if you call the Zip function directly.

  10. #10
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: Zipping Folders

    Windows XP zips by default, plus you can make a zip file yourself. Download a Microsoft DOCX format file, and open it. It's a zip file as well.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    303

    Re: Zipping Folders

    There is a link here on zipping files, have a look!

  12. #12
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,098

    Re: Zipping Folders

    jagio, please do not revive old threads.

    Rather start a new thread, and refer to the old thread.

  13. #13
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    303

    Re: Zipping Folders

    Just stumbled into this, could be handy.

  14. #14
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,999

    Re: Zipping Folders

    Just make sure you saw this:

    'Apparently you can only shell WinZip in vbHide mode if you have licensed
    'WinZip. If you are using the evaluation version, you need to run the shell in
    'vbNormalFocus mode. Then WinZip displays a message saying it is running in
    'evaluation mode and you must press a key to continue.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center