Page 1 of 1

Uncompress

Posted: Wed Jul 05, 2017 5:39 pm
by gcarrizo
Is posible extract a single file from a zipfile ?
i try use Uncompress , i read before source example ( \SAMPLES\Miscellaneous\ZIP ) but not found a detailed sintax or
example about it.
Sorry for my English.
Best Regards.

-----------------------------------------

¿Es posible extraer un solo archivo de un archivo zip?
Intentér usar Uncompress, he leído antes de fuente de ejemplo( \SAMPLES\Miscellaneous\ZIP ) , pero no encontré una sintaxis detallada o ejemplo acerca del mismo.

Saludos.

Re: Uncompress

Posted: Wed Jul 05, 2017 7:53 pm
by KDJ
gcarrizo

If MyZipFile.zip contains files:
File1.txt
File2.txt
File3.txt
example how to extract only File2.txt

Code: Select all

#include "hmg.ch"

FUNCTION Main()
  LOCAL cZipFile := "MyZipFile.zip"
  LOCAL cMyFile  := "File2.txt"
  LOCAL pUnzip   := HB_UnzipOpen(cZipFile)
  LOCAL nError
  LOCAL cFile

  IF ! Empty(pUnzip)
    nError := HB_UnzipFileFirst(pUnzip)

    DO WHILE nError == 0
      HB_UnzipFileInfo(pUnzip, @cFile)

      IF cFile == cMyFile
        HB_UnzipExtractCurrentFile(pUnzip, NIL /*cToFile*/, NIL /*cPassword*/)
        EXIT
      ENDIF

      nError := HB_UnzipFileNext(pUnzip)
    ENDDO

    HB_UnzipClose(pUnzip)
  ENDIF

RETURN NIL

Re: Uncompress

Posted: Thu Jul 06, 2017 11:30 am
by gcarrizo
It Work's Perfectly, Thanks

Best Regards

---------------------------------------
Funciona perfectamente, gracias
Saludos.

Re: Uncompress

Posted: Fri Jul 07, 2017 9:45 am
by edk
And here is another example using the progress bar.