Home » File/Folder Handling » How to List the all file names of a Zip file
How to List the all file names of a Zip file
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | 'File/Folder Handling - How to List the all file names of a Zip file Option Explicit Private Type ZFHeader Signature As Long version As Integer GPBFlag As Integer Compress As Integer Date As Integer Time As Integer CRC32 As Long CSize As Long USize As Long FNameLen As Integer ExtraField As Integer End Type Public Sub AddZIPfiles(ByVal ZIPfile As String, lst As ListBox) Dim FNum As Integer, iCounter As Integer Dim sResult As String Dim zhdr As ZFHeader Const ZIPSIG = &H4034B50 FNum = FreeFile Open ZIPfile For Binary Lock Read Write As #FNum Get #FNum, , zhdr While zhdr.Signature = ZIPSIG ReDim s(0 To zhdr.FNameLen - 1) As String * 1 For iCounter = 0 To UBound(s) s(iCounter) = Chr$(0) Next For iCounter = 0 To zhdr.FNameLen - 1 Get #FNum, , s(iCounter) Next Seek #FNum, Seek(FNum) + zhdr.CSize + zhdr.ExtraField sResult = "" For iCounter = 0 To UBound(s) sResult = sResult & s(iCounter) Next lst.AddItem sResult & Chr$(9) & Format$(zhdr.USize) Get #FNum, , zhdr Wend Close FNum End Sub 'How can I call this function: Private Sub Form_Load() Call AddZIPfiles("C:\Temp\TestFile.zip", List1) End Sub |
Enjoy this article?
Filed under: File/Folder Handling
Leave a comment