Results 1 to 5 of 5

Thread: HOW TO CREATE an empty zip file

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,579

    HOW TO CREATE an empty zip file

    HOW TO CREATE an empty zip file in c:\myzipfile\?

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: HOW TO CREATE an empty zip file

    The same way you would create any other file

    Code:
    open "c:\myzipfile\SomeFile.zip" for output as #1
    close #1

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: HOW TO CREATE an empty zip file

    Quote Originally Posted by DataMiser View Post
    The same way you would create any other file

    Code:
    open "c:\myzipfile\SomeFile.zip" for output as #1
    close #1
    Although if it is going to be empty then there is no much point in having it

  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: HOW TO CREATE an empty zip file

    An empty zip file has the same signature (20 Bytes i think). you can right click in explorer or your desktop and create a new empty zip file, to get the signature.

    Code:
        Open "SomeFile.zip" For Output As #1
        Print #1, "PK" & Chr(5) & Chr(6) & String$(18, 0);
        Close #1
    Last edited by DEXWERX; Oct 20th, 2017 at 09:23 AM. Reason: shortened even further...

  5. #5
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,034

    Re: HOW TO CREATE an empty zip file

    Hi,

    this is one way..

    Code:
    Private Sub Command1_Click()
    createZipFile "C:\myFirstZip.zip"
    End Sub
    
    Public Sub createZipFile(ByVal fileName As String)
        
        Dim fileNo As Integer
        Dim ZIPFileEOCD(22) As Byte
        
        'Signature of the EOCD:  &H06054b50
        ZIPFileEOCD(0) = Val("&H50")
        ZIPFileEOCD(1) = Val("&H4b")
        ZIPFileEOCD(2) = Val("&H05")
        ZIPFileEOCD(3) = Val("&H06")
        
        fileNo = FreeFile
        Open fileName For Binary Access Write As #fileNo
        Put #fileNo, , ZIPFileEOCD
        Close #fileNo
        
    End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Posting Permissions

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



Click Here to Expand Forum to Full Width