[RESOLVED] Use CGZipLibrary.dll to Zip & Unzip files
Hi guys,
I'm new to VB6 and I've to zip and unzip a folder (containing many files & subfolders). I've already read many threads about it but I couldn't find the correct answer to my problem.
This is what I done:
- I put the zip32.dll, Unzip32.dll & CGZipLibrary.dll into the Windows\System32 folder.
- I made the reference in Microsoft VB
- I wrote my code:
Code:
Dim oZip As CGZipFiles
Set oZip = New CGZipFiles
oZip.ZipFileName = "C:\temp\ZIP"
oZip.RecurseFolders = True
oZip.RootDirectory = "C:\Cerere"
oZip.AddFile "*"
If oZip.MakeZipFile <> 0 Then
MsgBox oZip.GetLastMessage
End If
Set oZip = Nothing
... but when I execute the program it doesn't work correctly... It creates the right file in the right directory, but it doesn't compress the right folder! If I open the zip files it contains the compressed folder: \Programs\Microsoft Visual Studio\ VB98 istead of C:\Cerere!!!
Why?????
Re: Use CGZipLibrary.dll to Zip & Unzip files
I have never used those DLLs. Did documentation come with it? Maybe there is another oZip property you need to set. It does sound like it is zipping from the current directory and not the target directory. Does c:\Cerere exist? Do you have to append a backslash to it: C:\Cerere\ ?
If none of those apply, maybe change directory before zipping and then reset after zipping.
Code:
Dim prevPath As String
prevPath = CurDir
ChDir "C:\Cerere"
' zip
ChDir prevPath
Re: Use CGZipLibrary.dll to Zip & Unzip files
Quote:
Originally Posted by LaVolpe
I have never used those DLLs. Did documentation come with it? Maybe there is another oZip property you need to set. It does sound like it is zipping from the current directory and not the target directory. Does c:\Cerere exist? Do you have to append a backslash to it: C:\Cerere\ ?
If none of those apply, maybe change directory before zipping and then reset after zipping.
Code:
Dim prevPath As String
prevPath = CurDir
ChDir "C:\Cerere"
' zip
ChDir prevPath
Thanks you very much!!!!!
I made everything you suggest except the last suggestion!
I put your code into mine & it works perfectly... I don't now why... but it works!
Thanks you! :wave:
Re: [RESOLVED] Use CGZipLibrary.dll to Zip & Unzip files
I have a problem when I try to unzip I get Run-time error '429'.
What program has to be installed to get this to stop? I have VB6. Does it require gzip or what?
Re: [RESOLVED] Use CGZipLibrary.dll to Zip & Unzip files
?
What program are you using to unzip your file? One that was created/compiled with VB6, or another one like Winzip?
If you used the OP's code, did you register the DLL's and do you have the correct paths to your files you are unzipping?
The 429 error is that you can't create an object, so i'd assume your DLL's aren't registered.