Page 1 of 2

using hb_unzipfile

Posted: Sat Mar 14, 2026 8:49 am
by kajot

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

best regards
kajot


Re: using hb_unzipfile

Posted: Sat Mar 14, 2026 8:59 am
by Antonio Linares

Dear Kajot,

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

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


Re: using hb_unzipfile

Posted: Sat Mar 14, 2026 9:24 am
by kajot

does hb_UnzipFile works in xHARBOUR


Re: using hb_unzipfile

Posted: Sat Mar 14, 2026 11:03 am
by kajot

function hb_zipfile work OK

but
hb_unzipfile don't unpack files

KAJOT


Re: using hb_unzipfile

Posted: Mon Mar 16, 2026 12:52 pm
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.


Re: using hb_unzipfile

Posted: Thu Mar 19, 2026 9:40 pm
by kajot

I am using xHarbour

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

it doesn't work


Re: using hb_unzipfile

Posted: Fri Mar 20, 2026 6:27 am
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) } )


Re: using hb_unzipfile

Posted: Fri Mar 20, 2026 12:14 pm
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


Re: using hb_unzipfile

Posted: Fri Mar 20, 2026 6:22 pm
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

Re: using hb_unzipfile

Posted: Sun Mar 22, 2026 6:33 pm
by Marc Vanzegbroeck

Re: using hb_unzipfile

Posted: Mon Mar 23, 2026 4:43 pm
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.


Re: using hb_unzipfile

Posted: Tue May 12, 2026 8:58 pm
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


Re: using hb_unzipfile

Posted: Wed May 13, 2026 4:37 pm
by karinha

Buenas tardes, muestre:

Code: Select all | Expand

   xPatLoc

Regards, saludos.


Re: using hb_unzipfile

Posted: Wed May 13, 2026 5:13 pm
by russimicro

C:\TEMP

asi funciona con windows 10/11


Re: using hb_unzipfile

Posted: Wed May 13, 2026 5:21 pm
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.