Archived Forum Post

Index of archived forum posts

Question:

ActiveX Zip.OpenZip Does Not seem to work?

Mar 16 '14 at 17:27

I am not getting very far with the ActiveX Zip component using VB6. I have developed a lot of code around these components and really like the ease of programming they make for me. But this one area seems to be non-functional. My goal is to Download a file to the PC from a Internet server (which works just fine). Then ask the User if they want to extract one of the files, renaming it just before unzipping it. As soon as the OpenZip Method is called on the downloaded file, the error occurs (Did not find central file header signature.) which makes no sense to me. The file being downloaded was created with the Zip component and uploaded to the server. I am running Windows 7, .Net 4, VB6 SP6, WinRar, with Chilkat Mail (purchased), Zip and FTP2 (evaluating for purchase). Can anyone tell me if I have it wrong or this piece just doesn't work properly???? UPDATE: I just figured out this isn't the issue, it's the creation of the zip. If I build it without Chilkat it works fine????

'Download Zip File Set ftp = New ChilkatFtp2

success = ftp.UnlockComponent("30-day trial")
If (success = 0) Then
    MsgBox "Failed to unlock component"
    Exit Sub
End If

' Set our heartbeat interval to .1 seconds
' This causes ftp_AbortCheck to be called approximately every .1 seconds.
ftp.HeartbeatMs = 100

' Set the FTP hostname, login, and password.
ftp.HostName = "MyHost.com"
ftp.UserName = "UserName"
ftp.Password = "Passwd"
ftp.Port = 21

' Connect and login to the FTP server.
success = ftp.Connect()
If (success = 0) Then
    MsgBox ftp.LastErrorText
    Exit Sub
End If
'  Change to the remote directory where the file will be Downloaded.
success = ftp.ChangeRemoteDir("MyHost.us/DB")
If (success <> 1) Then
    MsgBox ftp.LastErrorText
    Exit Sub
End If

' Download file 
localfile = arcDir & "\" & DriveChallange & ".zip"
remoteFile = DriveChallange & ".zip"
success = ftp.GetFile(remoteFile, localfile)
If (success = 0) Then
    MsgBox ftp.LastErrorText
    Exit Sub
End If

ftp.Disconnect

X = MsgBox("Would you like to extract the Park.MDB from the Download as Park" & Format(Now, "mm-dd-yyyy") & ".MDB in your " & arcDir & " Directory?" & vbCrLf & "None of the other Files will be extracted.", vbYesNo)
If X = 6 Then
    Dim zip As New ChilkatZip2
    localfile = arcDir & "\" & DriveChallange & ".zip"

    '  Any string unlocks the component for the 1st 30-days.
    success = zip.UnlockComponent("Anything for 30-day trial")
    If (success <> 1) Then
        MsgBox zip.LastErrorText
        Exit Sub
    End If

    success = zip.OpenZip(localfile)
    If (success <> 1) Then
        MsgBox zip.LastErrorText 'This is where it fails
        Exit Sub
    End If

    Set entry = zip.GetEntryByName("Park.MDB")
    entry.filename = "NewPark.MDB"
    zip.UnzipInto ("C:/lusbydata/vb6")
    If (entry Is Nothing) Then
        MsgBox "Couldn't find file"
    Else
        'Process File
    End If
    zip.CloseZip
End If

ChilkatLog: OpenZip: DllDate: Dec 19 2013 ChilkatVersion: 9.4.1.88 UnlockPrefix: Anything for 30-day trial Username: LUZLAPTOP:Luz Architecture: Little Endian; 32-bit Language: ActiveX VerboseLogging: 0 zipPath: C:LusbyDataVB6RVPark3001J9e5E8d9.zip oemCodePage: 437 openFromMemData: numCentralDirEntries: 6 szCentralDir: 341 posCentralDir: 1127169 Did not find central file header signature. index: 0 filePos: 1127169 --openFromMemData Failed. --OpenZip --ChilkatLog


Answer

I found (after many hours) that, when I updated my purchased WinRAR instance, everything started working correctly. When I used WinRAR (the old version) and Zipped several files and then opened it with WinRAR, the top line said the file name and then "ZIP archive", but when I used Chilkat to zip the files under the older version of WinRAR on my PC, the line said "SFX archive" (Version 5.00 vs 5.01) It isn't clear how Chilkat's DLLs are affected by another application, but at least I am working correctly. I am a little cautious about buying and implementing into my software when a client may get errors if they have WinRAR 5.00 ...