ListArchive Example


Displays all files inside in the input ZIP file (strArchiveFile).
Please note that only files in the root folder of the ZIP file are displayed.

VBScript Code

Copy Code
 Sub ListArchive(strArchiveFile)
      ' Open the ZIP archive
      Dim pArchive
      Set pArchive = Application.CreateAppObject("Archive")
      If (Not pArchive.Open(strArchiveFile)) Then Exit Sub
      ' Retrieve a list of files in the root folder
      Dim arrFileList, strOutput
      arrFileList = pArchive.FindFiles("*")
      ' Build up a string containing the names of all files in the list
      If (IsArray(arrFileList)) Then
            strOutput = CStr(UBound(arrFileList) - LBound(arrFileList) + 1) & " file(s) in archive " & strArchiveFile & "."
            Dim strFile
            For Each strFile In arrFileList
                  strOutput = strOutput & vbNewline & strFile
            strOutput = "No files in archive."
      End If
      ' Close the ZIP archive
      ' Display the list of files found
      Application.MessageBox strOutput, apInformation, "ListArchive"
End Sub