Page 1 of 1
[SOLVED] How to unzip a zipped file?
Posted: Mon Jan 18, 2021 9:35 am
by SkyManager
Could anybody provide an example pb how to unzip a zipped file?
I cannot figure out how to use pb UseZipPacker()??????
Regards,
SkyManager
Re: How to unzip a zipped file?
Posted: Mon Jan 18, 2021 9:47 am
by loulou2522
Here is an example with zip file
Purpose: To extract from a zip file all files with a PDF, JPEG or PNG extension.
Code: Select all
UseZipPacker()
If OpenPack(0, fichier$,#PB_PackerPlugin_Zip)
If ExaminePack(0)
While NextPackEntry(0)
If PackEntrySize(0,#PB_Packer_UncompressedSize) > 0 And ( UCase(GetExtensionPart(PackEntryName(0)))= "PDF" Or UCase(GetExtensionPart(PackEntryName(0)))= "PNG" Or UCase(GetExtensionPart(PackEntryName(0))) = "JPEG" ) And ( PackEntryType(0) = #PB_Packer_File )
UncompressPackFile(0, GetTemporaryDirectory()+PackEntryName(0) , PackEntryName(0))
EndIf
Wend
EndIf
ClosePack(0)
Re: How to unzip a zipped file?
Posted: Mon Jan 18, 2021 9:54 am
by firace
Here's the simplest example I have in my code library:
Code: Select all
UseZipPacker()
zipfilelocation$ = "C:\test\archive.zip"
destfolder$ = GetTemporaryDirectory() + "test_unzip\"
CreateDirectory(destfolder$ )
OpenPack(0, zipfilelocation$)
ExaminePack(0)
while NextPackEntry(0)
UncompressPackFile(0, destfolder$ + filename$)
wend
ClosePack(0)
Re: How to unzip a zipped file?
Posted: Tue Jan 19, 2021 1:04 am
by SkyManager
thanks a lot