using hb_unzipfile

User avatar
kajot
Posts: 375
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland
Been thanked: 1 time

using hb_unzipfile

Post by kajot »

how can I unpack file "paczka1.zip" to folder ".\kat1" using hb_unzipfile

best regards
kajot

best regards
kajot
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: using hb_unzipfile

Post by Antonio Linares »

Dear Kajot,

hb_UnzipFile( "paczka1.zip",, .T.,, ".\kat1" )

FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles, bProgress )

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
kajot
Posts: 375
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland
Been thanked: 1 time

Re: using hb_unzipfile

Post by kajot »

does hb_UnzipFile works in xHARBOUR

best regards
kajot
User avatar
kajot
Posts: 375
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland
Been thanked: 1 time

Re: using hb_unzipfile

Post by kajot »

function hb_zipfile work OK

but
hb_unzipfile don't unpack files

KAJOT

best regards
kajot
User avatar
karinha
Posts: 8716
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Has thanked: 33 times
Been thanked: 51 times
Contact:

Re: using hb_unzipfile

Post by karinha »

Code: Select all | Expand

   // -- Testa se pode extrair ou não
      IF lExtrai

     Result := hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

  ENDIF

https://fivewin.com.br/index.php?/topic ... ia/page/3/

viewtopic.php?f=6&t=30003&p=175748&hili ... le#p175748

viewtopic.php?f=6&t=24038&p=129404&hili ... le#p129404

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
kajot
Posts: 375
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland
Been thanked: 1 time

Re: using hb_unzipfile

Post by kajot »

I am using xHarbour

Result := hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

it doesn't work

best regards
kajot
User avatar
Antonio Linares
Site Admin
Posts: 44508
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 717 times
Been thanked: 311 times
Contact:

Re: using hb_unzipfile

Post by Antonio Linares »

Dear Kajot,

The variable pUnzip is only assigned if parameter 6 is an array or string. But pUnzip is not initialized — if
parameter 6 is missing/NIL, pUnzip has an undefined value, and the code at line 754 (if( pUnzip )) could behave
unpredictably.

More importantly, the 6th parameter (paFile) is mandatory. From the docs:

▎ If <cFile> or <aFiles> are not provided, no files will be extracted!

Your call is:

hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

This looks syntactically correct. The problem could be one of these:

  1. paFile is empty or NIL — make sure it contains the actual filenames inside the zip. Use hb_GetFilesInZip() first to
    get them:

paFile := hb_GetFilesInZip( cZipFile )
Result := hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

  1. pcDestPath must end with a backslash — the C code uses it directly as a path:

    pcDestPath := "C:\MyFolder\" // must end with backslash

  2. The path must already exist — lWithPath (.T.) creates subdirectories within the zip structure, but the destination
    folder itself must exist.

  3. File names in paFile must match exactly what's stored in the zip (including paths inside the zip). Check with:

    aFiles := hb_GetFilesInZip( cZipFile )
    AEval( aFiles, {|c| QOut(c) } )

regards, saludos

Antonio Linares
www.fivetechsoft.com
russimicro
Posts: 413
Joined: Sun Jan 31, 2010 3:30 pm
Location: Bucaramanga - Colombia
Been thanked: 5 times

Re: using hb_unzipfile

Post by russimicro »

Antonio

Solucionado... Gracias

Code: Select all | Expand

              vFilXml := hb_GetFilesInZip( cFilZip )

          IF LEN(vFilXml) == 0
             AADD(aErrZip,{cFilZip,"","Archivo .zip no contiene archivos "})
          ELSE

             //  RUN ("7z x " +cFilZip+ " -o"+  xPatLoc +" -y *.xml -bso0 -bsp0 -bse0" )

             hb_UnzipFile( cFilZip,, .T.,, xPatLoc+"\", vFilXml )
             cFilXml := ""
             for K := 1 to len(vFilXml)
                 IF Lower(Right(vFilXml[K], 4)) == ".xml"
                    cFilXml :=  ALLTRIM(vFilXml[K])  // analiza el primer xml encontrado... no deberian existir mas de uno!!
                    exit
                 ENDIF
             next

             cFilXmlIni := cFilXml
             cFilXml := xPatLoc+"\"+cFilXml

             IF !fileExiste(cFilXml)
                AADD(aErrZip,{cFilZip,cFilXml,"Archivo XML no existe"})
             ELSE
             //
             ENDIF

User avatar
kajot
Posts: 375
Joined: Thu Nov 02, 2006 6:53 pm
Location: Poland
Been thanked: 1 time

Re: using hb_unzipfile

Post by kajot »

my sample

Code: Select all | Expand

sc0 :=curdrive()+':'+'\'+curdir()+'\'
 zb:='PaczkaFaktur.zip'

 if file(zb)
      aFiles := hb_GetFilesInZip( zb , .t.)         
      AEval( aFiles, {|c| QOut(c) } )

      IF LEN(aFiles) > 0
   

         lOK:=hb_UnzipFile( zb,,.T.,, sc0, aFiles)

         alert(iif(lOK, "OK", "NO") )

      else
         alert('Zip nie zawiera plikow.')

      endif
  else
      alert('Brak zbioru '+zb)
  endif
best regards
kajot
Marc Vanzegbroeck
Posts: 1195
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Been thanked: 4 times
Contact:

Re: using hb_unzipfile

Post by Marc Vanzegbroeck »

Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
karinha
Posts: 8716
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Has thanked: 33 times
Been thanked: 51 times
Contact:

Re: using hb_unzipfile

Post by karinha »

Marc Vanzegbroeck wrote: Sun Mar 22, 2026 6:33 pm

Look at this
viewtopic.php?p=175748&hilit=hb_UnzipFileRevd#p175748

Original:

Javier lloris,

https://code.google.com/archive/p/fuent ... /downloads

Many thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
russimicro
Posts: 413
Joined: Sun Jan 31, 2010 3:30 pm
Location: Bucaramanga - Colombia
Been thanked: 5 times

Re: using hb_unzipfile

Post by russimicro »

Buena tarde .

vFilXml := hb_GetFilesInZip( cFilZip )

hb_UnzipFile( cFilZip,, .T.,, xPatLoc+"\", vFilXml )

Error en windows server 2022 se aborta, sin mensajes , sin log

windows 10/11 ok perfecto SIN ERROR Y EN PRODUCCION

JONSSON RUSSI

User avatar
karinha
Posts: 8716
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Has thanked: 33 times
Been thanked: 51 times
Contact:

Re: using hb_unzipfile

Post by karinha »

Buenas tardes, muestre:

Code: Select all | Expand

   xPatLoc

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
russimicro
Posts: 413
Joined: Sun Jan 31, 2010 3:30 pm
Location: Bucaramanga - Colombia
Been thanked: 5 times

Re: using hb_unzipfile

Post by russimicro »

C:\TEMP

asi funciona con windows 10/11

User avatar
karinha
Posts: 8716
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Has thanked: 33 times
Been thanked: 51 times
Contact:

Re: using hb_unzipfile

Post by karinha »

russimicro wrote: Wed May 13, 2026 5:13 pm

C:\TEMP

asi funciona con windows 10/11

Code: Select all | Expand

#Include "FiveWin.ch"

MEMVAR cDirPleno

FUNCTION Main()

   LOCAL cFile, cPathImg

   cDirPleno := GETCURDIR()

   // Windows Server problems.
   IF SUBS( cDirPleno, LEN( ALLTRIM(cDirPleno ) ) , 1 ) = "\"
      cDirPleno := SUBS( cDirPleno, 1 , LEN( ALLTRIM(cDirPleno ) ) - 1 )
   ENDIF

   LCHDIR( cDirPleno )

   cPathImg := cDirPleno + "\"+ "*.BMP"

   // cFile := CGETFILE( "File Excel (*.xls;*.xlsx)|*.xls;*.xlsx", "Import from", , CURDRIVE() + ":\" + CURDIR() )

   cFile := cGetFile( "*.bmp|*.bmp|", "Selecione um Arquivo Bitmap (.BMP)",,"cPathImg" )

   IF Empty( cFile )

  XImage( cFile )

   ENDIF

RETURN NIL

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Post Reply