Advertisement
7_2009-2012 Files/ File Controls/ Input/ Output #239279

Zip a file or folder using no 3rd Partys apps/DLL'S

This code will zip any file or folder

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Sub Command1_Click()
  CreateEmptyZip "c:\testzip.zip"
  
  With CreateObject("Shell.Application")
    .NameSpace("c:\testzip.zip").CopyHere "c:\FirePassword.exe"
    ' .NameSpace("c:\testzip.zip").CopyHere .NameSpace(FolderName).items 'use this line if we want to zip all items in a folder into our zip file
  End With
  ' All done!
End Sub

Public Sub CreateEmptyZip(sPath)
  Dim strZIPHeader As String
  strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0) ' header required to convince Windows shell that this is really a zip file
  With CreateObject("Scripting.FileSystemObject")
    .CreateTextFile(sPath).Write strZIPHeader
  End With
  
End Sub
Original Comments (3)
Recovered from Wayback Machine