Implementing the CompressedFolder Class - More internal methods
(Page 2 of 4 )
Private Function AddFiles(strFolder, varSource, blnKeepOriginal)
If IsArray(varSource) Then
For Each strPath In varSource
AddFile strFolder, strPath, blnKeepOriginal
Next
Else
Set colItems = objShell.NameSpace(strSource).Items
intCount = .Items.Count
Select Case CBool(blnKeepOriginal)
Case True
objShell.NameSpace(strFolder).CopyHere colItems, 1548
Case False
objShell.NameSpace(strFolder).MoveHere colItems, 1548
End Select
Do Until objShell.NameSpace(strFolder).Items.Count = intCount + colItems.Count
Sleep 200
If Not ShellBusy Then Exit Do
Loop
End If
End Function
The AddFiles method is mirrored by the public AddMultiple method. It is basically a rewrite of the AddFile method you just saw, with the exception that you can add multiple files at one time from either an array or an existing folder. It functions identically to the AddFile method, except that it works recursively through the provided object.
Private Function ExtractAll(strZipFile, strFolder)
If Not objFso.FolderExists(strFolder) Then objFso.CreateFolder(strFolder)
intCount = objShell.NameSpace(strFolder).Items.Count
Set colItems = objShell.NameSpace(strZipFile).Items
objShell.NameSpace(strFolder).CopyHere colItems, 1548
Do Until objShell.NameSpace(strFolder).Items.Count = intCount + colItems.Count
Sleep 200
If Not ShellBusy Then Exit Do
Loop
End Function
Finally, the ExtractAll method is mirrored by the public Extract method. This method is used to copy, or extract, files from an existing compressed folder. Again, I’m basically just covering the use of the Shell Object.
Next: Examining the Support Methods >>
More Code Examples Articles
More By Nilpo