[AccessD] ZIpping Files

Stuart McLachlan stuart at lexacorp.com.pg
Wed Feb 18 05:06:38 CST 2009


On 17 Feb 2009 at 10:30, Arthur Fuller wrote:

> Pretty neat! It could use a third function that lists the files and folders
> with a given zip file. Then it would be totally slick.

Had to think about that one a bit :-)
Because a Compressed (Zipped) folder can contain other folders, we need a recursive 
function, called by a wrapper function.  

Function EnumerateZipContents(ZipFileName As String) As Variant
'Returns an Array containing all folder and file names in the zip
  EnumerateZipContents = Split(ListFilesInZipFolder(ZipFileName), Chr$(13) & Chr$(10))
End Function

Function ListFilesInZipFolder(ZipFileName As String) As String
  Dim oShellApp As Shell32.Shell 
  Dim ofile As Object
  Dim strNames As String
  Set oShellApp = CreateObject("Shell.Application")
  For Each ofile In oShellApp.NameSpace(ZipFileName).Items
    If ofile.IsFolder Then
        strNames = strNames & "Fldr: " & ZipFileName & "\" & ofile.Name & Chr$(13) & 
Chr$(10)
        strNames = strNames & ListFilesInZipFolder(ZipFileName & "\" & ofile.Name)
    Else
       strNames = strNames & "File: " & ZipFileName & "\" & ofile.Name & Chr$(13) & 
Chr$(10)
    End If
  Next
  ListFilesInZipFolder = strNames
End Function


-- 
Stuart




More information about the AccessD mailing list