Provides Zip archive functionality for creating and extracting of zip files.
Using this class you can:
- Add files in batch using paths or wildcards optionally recursively
- Append files
- Unzip an archive into a folder
- Unzip individual files
- Get a listing of all files and selectively extract files
Remarks
- This library uses wwDotnet bridge
- Dependencies:
- wwipstuff.dll
- wwDotnetBridge.dll
Class Members
Member | Description | |
---|---|---|
AppendFiles |
An extended Zip function that allows more control over zip archiving that provides multiple files and wildcards. AppendFiles(lcZipFile,lcFiles,lcBaseFolder, llRecurse,llFast) |
|
GetZipEntries |
Get a list of entries for the files contained inside of the zip file as a FoxPro Collection .o.GetZipEntries(lcZipFile) |
|
UnzipFile |
Retrieves an individual file from a zip archive and saves it to disk. o.UnzipFile(lcZipFile, lcEntry, lcTargetFile) |
|
UnzipFolder |
Unzips the complete contents of a Zip file into a folder. o.UnzipFolder(lcZipFile, lcTargetFolder) |
|
ZipFiles |
Creates a zip file from a list of files. ZipFiles(lcZipFile,lcFiles,lcBaseFolder, llRecurse,llFast) |
Example
*** Load library and dependencies
DO wwZipArchive
loZip = CREATEOBJECT("wwZipArchive")
lcZipFile = "d:\temp\zipFiles.zip"
*** Zip up a folder with multiple wildcards
IF !loZip.ZipFiles(;
lcZipFile,;
"*.fpw,*.vc?,*.dll,*.h",;
CURDIR(), .T.)
? "Zipping Error: " + loZip.cErrorMsg
RETURN
ENDIF
? loZip.cErrorMsg
*** add another file
*** Note: You can add many files using same syntax as ZipFiles() above
IF !loZip.AppendFiles(lcZipFile, "wwZipArchive.prg")
? "Error: " + loZip.cErrorMsg
RETURN
ENDIF
*** Unzip all into a folder
IF !loZip.UnzipFolder(lcZipFile, "d:\temp\Unzipped1")
? "Unzip Error: " + loZip.cErrorMsg
RETURN
ENDIF
*** Look at all files in the zip
loEntries = loZip.GetZipEntries(lcZipFile)
IF ISNULL(loEntries)
? "No entries: " + loZip.cErrorMsg
RETURN
ENDIF
? loEntries.Count
*** Iterate through the collection
FOR EACH loEntry IN loEntries FoxObject
? loEntry.Name + " " + ;
loEntry.Fullname + " " + ;
TRANSFORM(loEntry.Length) + " - " + ;
TRANSFORM(loEntry.CompressedLength)
ENDFOR
*** Unzip an individual entry and unzip it - first in this case
loZip.UnzipFile(lcZipFile, loEntries[1].FullName, "d:\temp\" + loEntries[1].Name)
© West Wind Technologies, 2024 • Updated: 06/01/24
Comment or report problem with topic