Este es el sitio web histórico de la documentación de 4D. La documentación se está trasladando progresivamente a developer.4d.com

Inicio

 
4D v19.8
ZIP Read archive

ZIP Read archive 


 

ZIP Read archive ( zipFile {; password} ) -> Resultado 
Parámetro Tipo   Descripción
zipFile  Objeto in ZIP archive file
password  Texto in ZIP archive password if any
Resultado  Objeto in Archive object

The ZIP Read archive command retrieves the contents of zipFile and returns it as an object. 

Note: This command does not uncompress the ZIP archive, it only provides a view of its contents. To extract the contents of an archive, you need to use methods such as file.copyTo( ) or folder.copyTo( ).

Pass a File object referencing the compressed ZIP archive in the zipFile parameter. The target archive file will be opened until the ZIP Read archive has finished executing and all contents/references have been extracted /released, then it will be closed automatically. 

If the zipFile is password protected, you need to use the optional password parameter to provide a password. If a password is required but not passed when trying to read the contents of the archive, an error is generated.

 

Returned object

The returned object contains a single "root" property whose value is a Folder object. This folder describes the whole contents of the ZIP archive:

 

 Property  Type  Description
 root  object A virtual folder containing the contents of the ZIP archive.

 

The "root" folder and its contents can be manipulated with the File and Folder methods and properties.

Ejemplo  

To retrieve and view the contents of a ZIP file object:

 C_OBJECT($archive;$path)
 
 $path:=Folder(fk desktop folder).file("MyDocs/Archive.zip")
 $archive:=ZIP Read archive($path)

 

To retrieve the list of the files and folders in the archive:

 $folders:=$archive.root.folders()
 $files:=$archive.root.files()

 

To read the contents of a file without extracting it from the root folder:

 If($files[$i].extension=".txt")
    $txt:=$files[$i].getText()
 Else
    $blob:=$files[$i].getContent()
 End if

 

To extract from the root folder:

  //extract a file
 $folderResult:=$files[$i].copyTo(Folder(fk desktop folder).folder("MyDocs"))
 
  //extract all files
 $folderResult:=$archive.root.copyTo(Folder(fk desktop folder).folder("MyDocs"))



Ver también 

Archivo y carpeta
Sobre los archivos ZIP
ZIP Create archive

 
PROPIEDADES 

Producto: 4D
Tema: Archivo y carpeta
Número 1637

This command can be run in preemptive processes

 
CONTENIDO DE LA PÁGINA 
 
HISTORIA 

Creado por: 4D v18

 
ARTICLE USAGE

Manual de lenguaje 4D ( 4D v19.5)
Manual de lenguaje 4D ( 4D v19.6)
Manual de lenguaje 4D ( 4D v19.7)
Manual de lenguaje 4D ( 4D v19.8)