0

I am fairly new to the developing. I am using vb6 at my work and currently trying to zip a particular folder including multiple files. Is this possible without using any third party programs?

All the materials that I have found so far is about zipping only one file.

Thank you:)

pugmaster
  • 1
  • 2
  • 1
    Try [Google](http://www.codeguru.com/vb/gen/vb_graphics/fileformats/article.php/c6743/Zip-and-Unzip-Using-VB5-or-VB6.htm)? – C-Pound Guru Jul 20 '16 at 20:46
  • 1
    Possible duplicate of [Can Windows' built-in ZIP compression be scripted?](http://stackoverflow.com/questions/30211/can-windows-built-in-zip-compression-be-scripted) – jac Jul 20 '16 at 22:26
  • 1
    By third party programs do you mean external DLLs? You'e certainly not going to do it yourself in VB6. You can use wrappers or classes for zipp DLLs but I don't think you're a person willing ot build your own zip/unzip paclage just to avoid using a zip dll – dbmitch Jul 20 '16 at 22:27

1 Answers1

0

Looks like Folder.CopyHere would help. However it does not notify the program when the copy has completed.

Dim s As String
s = "C:\FullPathToZipFile"
'create a new zip file
Open s For Binary As #1
Dim zipd
zipd = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Dim zip(21) As Byte
Dim i As Long
For i = 0 To 21
    zip(i) = zipd(i)
Next
Put #1, , zip
Close #1
Dim objShell As Object
Set objShell = CreateObject("Shell.Application")
Dim objZip As Object, objFolder As Object
Set objZip = objShell.NameSpace(s)
If Not objZip Is Nothing Then
    Set objFolder = objShell.NameSpace("C:\FullPathToYourFiles")
    If Not objFolder Is Nothing Then
        objZip.CopyHere objFolder.Items
    End If
End If

Alternatively (maybe) you can implement Compression API

vincent163
  • 384
  • 2
  • 13