Extracting a ZIP File

Article Tools

Windows XP has a built-in ZIP mechanism integrated into its file-system. We can easily use this to extract standard ZIP files with only a few commands:

 1: 'Variable Definition
 2: Dim sZIPFile
 3: Dim sExtractToPath
 4:
 5: Dim oShell
 6: Dim oZippedFiles
 7:
 8: 'Variable Initialization
 9: sZIPFile="C:\Source.zip"
 10: sExtractToPath="C:\Dest\InnerDir\"
 11: Set oShell = CreateObject("Shell.Application")
 12:
 13: 'Get the contents of the ZIP archive
 14: Set oZippedFiles=oShell.NameSpace(sZIPFile).items
 15:
 16: 'Copy the contents into the destination folder
 17: oShell.NameSpace(sExtractToPath).CopyHere(oZippedFiles)
 18:
 19: 'Free Objects
 20: Set oZippedFiles = Nothing
 21: Set oShell = Nothing
 22:
Previous postYou can now open QTP 9.5 tests with QTP 9.2! Next postCreating a ZIP Archive

Related Posts

Post Your Comment

You must be logged in to post a comment.