Iphone development: Open zip

Source: Internet
Author: User
Tags ziparchive

The usage is as follows:

Create/Add a zip package
ZipArchive * zipFile = [[ZipArchive alloc] init];
// For zipfilename, a complete path is required, for example, ***/Documents/demo.zip.
[ZipFile CreateZipFile2: @ "zipfilename"];
// There are two optional methods to create a compressed package, with or without a password
[[ZipFile CreateZipFile2: @ "zipfilename" Password: @ "your password"];
// Add the file to be compressed to this package
// The complete path is required for the first parameter. For example, ***/Documents/a.txt newname indicates the name of the file in the compressed package.
[ZipFile addFileToZip: @ "fullpath of the file" newname: @ "new name of the file without path"];
// If You Need To Compress multiple files, that is, to compress the folder, repeat the addFileToZip method.
[ZipFile CloseZipFile2];
[ZipFile release];
// Release the memory

Decompress the zip package:
ZipArchive * zipFile = [[ZipArchive alloc] init];
[ZipFile UnzipOpenFile: @ "zip file name"];
// Similarly, there are two methods to open the zip package, with or without a password
[ZipFile UnzipOpenFile: @ "zip file name" Password: @ "password"];
// The location where the compressed package is released. A complete path is required.
[ZipFile UnzipFileTo: @ "output path" overwrite: YES];
[ZipFile UnzipCloseFile];
[ZipFile release];
// Remember to release

 

 


From cloud huaikong-abel

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.