Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/plugins/qtranslate-x/qtranslate_frontend.php on line 497

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/themes/suffusion/functions/media.php on line 666

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/themes/suffusion/functions/media.php on line 671

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/themes/suffusion/functions/media.php on line 684

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/themes/suffusion/functions/media.php on line 689

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/vhosts/cadetill.com/domains/cadetill.com/public_html/wp-content/themes/suffusion/functions/media.php on line 694
La unit Zip y la clase TZipFile – El blog de cadetill
feb 102013
 

Buenas

Post in two languages / Mensaje en dos idiomas:


spanish flag Para demostrar el uso de la unidad Zip, he realizado una pequeña aplicación, la WinZLB. En ella demuestro cómo abrir o crear archivos comprimidos con esta unidad, así como añadir o extraerlos.

El funcionamiento es muy sencillo. Primero crearemos un objeto de tipo TZipFile

FZLB := TZipFile.Create;

Para crear un nuevo archivo comprimido, usaremos el método Open con TZipMode zmWrite.

FZLB.Open(SaveDialog1.FileName, zmWrite);

Para abrir un archivo existente, usaremos el método Open con TZipMode zmReadWrite

FZLB.Open(OpenDialog1.FileName, zmReadWrite);

Para añadir archivos al fichero comprimido usaremos el método Add

FZLB.Add(OpenDialog1.Files[i]);

Y para extraer los ficheros, el método Extract

FZLB.Extract(lvData.ItemIndex, FileOpenDialog1.FileName);

No tenemos que olvidarnos de la destrucción del objeto.

A parte de esto, podemos jugar con los métodos de compresión y con la información de los archivos comprimidos.

Para más información acerca de esta unidad, podéis consultar la wiki de Embarcadero.

Puedes descargar los fuentes desde aquí.



english flag To show how to use the Zip unit, I did a very small application, the WinZLB. In this application I show how open or create compressed files with this unit, as well as add files or extract it.

The operation is very simple. First we need to create an object of type TZipFile

FZLB := TZipFile.Create;

To create a new compressed file, we will use the Open method with TZipMode zmWrite.

FZLB.Open(SaveDialog1.FileName, zmWrite);

To open an existing file, we will use the Open method with TZipMode zmReadWrite

FZLB.Open(OpenDialog1.FileName, zmReadWrite);

To add files to the compressed file we will use the Add method

FZLB.Add(OpenDialog1.Files[i]);

And to extract files, the Extract method

FZLB.Extract(lvData.ItemIndex, FileOpenDialog1.FileName);

We must not forget the destruction of the object.

Apart from this, you can play with the compression methods and with the information of compressed files.

For more information about this unit, see the wiki from Embarcadero.

You can download source code from here.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.