[SOLVED] How to unzip a zipped file?

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

[SOLVED] How to unzip a zipped file?

Post 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
Last edited by SkyManager on Tue Jan 19, 2021 1:04 am, edited 1 time in total.
loulou2522
Enthusiast
Enthusiast
Posts: 495
Joined: Tue Oct 14, 2014 12:09 pm

Re: How to unzip a zipped file?

Post 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)
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: How to unzip a zipped file?

Post 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)
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

Re: How to unzip a zipped file?

Post by SkyManager »

thanks a lot
Post Reply