i have the code to open zip and se its contents but how do i check each file crc?
am not at home now so please share what you can thank you.
Printable View
i have the code to open zip and se its contents but how do i check each file crc?
am not at home now so please share what you can thank you.
Computing the crc for a file is a well-established algorithm. You can many examples on this site. While your aware from home, you may want to try this google search: crc file site:vbforums.com
JFYI, the original cZipArchive class has a public CalcCrc32Array function that is based on libdeflate's crc32_slice4 implementation and I'm 99% sure this can beat any VB6 implementation in benchmarking (left 1% for if Olaf chimes in:-)).
cheers,
</wqw>
If you make use of zlibwapi.dll you can get the CRC along with the Name (and other things if you really want them) of each item.
Here's a wrapper class for the purpose.
Attachment 171669
You'll need a version of zlibwapi.dll in the EXE folder, or somewhere along the paths in the PATH environment variable, or a path spelled out in a manifest, etc. Somewhere that the DLL search can find it.
The easiest way that I'm aware of is described here.
Wolfgang
how to get file byte from DLL API?
LIKE THIS?
How to unpack a ZIP file using the library zlibwapi.dll ?-VBForums
https://www.vbforums.com/showthread....y-zlibwapi-dll
Code:Sub GetFileList(FileList() As String)
Dim crc As Long
Dim Path As String
Dim Listc As New Collection
FirstFile Path, crc
Do While Len(Path)
Listc.Add Path
NextFile Path, crc
Loop
If Listc.Count > 0 Then
ReDim FileList(Listc.Count - 1)
Dim v
Dim ID As Long
ID = 0
For Each v In Listc
FileList(ID) = v
ID = ID + 1
Next
Else
ReDim FileList(-1 To -1)
End If
End Sub
Code:Option Explicit
Private Declare Function RtlComputeCrc32 Lib "ntdll.dll" (ByVal dwInitial As Long, ByVal pData As Long, ByVal iLen As Long) As Long
Private Function Crc32Api(tBuff() As Byte) As Long
Crc32Api = RtlComputeCrc32(0, VarPtr(tBuff(0)), UBound(tBuff) + 1)
End Function