VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



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

by Mason Reece Soiza (2 Submissions)
Category: Files/File Controls/Input/Output
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

This code will zip any file or folder

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

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

Download this snippet    Add to My Saved Code

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

No comments have been posted about Zip a file or folder using no 3rd Partys apps/DLL'S. Why not be the first to post a comment about Zip a file or folder using no 3rd Partys apps/DLL'S.

Post your comment

Subject:
Message:
0/1000 characters