Home > ZipArchive > Frequently Asked Questions
Frequently Asked Questions
Applies To: All
• If you receive LNK2005, your application probably uses different run-time libraries that the ZipArchive Library was compiled for.
• If you receive LNK1104 (e.g. cannot open the mfc42u.lib file), you probably haven't installed Unicode libraries.
• If you receive C2872 among others in a C++/CLI application, you need to correct the linking order.
To read about detailed solutions, see Compilation of the ZipArchive Library and Integration with Applications.

### How to compile the library for x64 under Microsoft Visual Studio?

See Compilation of the ZipArchive Library and Integration with Applications for the instructions.

### How to create an archive larger than 4GB or compress more than 65535 files inside it?

The standard zip format does not support large archives or large files inside archives (even if a compressed file was smaller than 4GB). You need to use the Zip64 extensions. See Zip64 Format: Crossing the Limits of File Sizes and Number of Files and Segments for more information. This functionality is available only to the purchasers of the Full Version license.

### How to use UNC paths of very long paths (longer than MAX_PATH) under Windows?

See Compilation of the ZipArchive Library and Integration with Applications for the solution.

### Why I can't make the library to work as expected in a MFC application?

Make sure that your application defines _ZIP_IMPL_MFC. See Compilation of the ZipArchive Library and Integration with Applications for more information.

### Why the library doesn't extract archives?

• Some archives are not entirely consistent in their structure, however the compressed data may be correct. Try relaxing some of the consistency checks with the CZipArchive::SetIgnoredConsistencyChecks() method.
• Another reason is that data in the archive is compressed using imploded method (usually by old archivers). The ZipArchive Library supports only deflation (which is the most commonly used by archivers) and storing. To determine the compression method for a particular file, obtain the information data (see Requesting Information, Predicting Names and Sizes) and examine the CZipFileHeader::m_uMethod field.

### Why I receive the CZipException::cdirNotFound exception when trying to open a segmented archive?

You need to open the last segment. For more information about dealing with this problem in spanned archives, see Segmented Archives: Splitting and Spanning.

### How can I detect the segmentation mode of an archive?

You need to open the archive and the call CZipArchive::GetStorage() and then CZipStorage::IsSegmented()s.

### How to use a partial path for the filename inside an archive?

For example, if you compress a directory c:\Program Files\Example, the full path of the file inside the archive is stored. If you would like to store the path for the file, e.g. in c:\Program Files\Example\text\txt\file.dat, as Example\text\txt\file.dat, use the CZipArchive::SetRootPath() method. In this example, you would set it to c:\Program Files\. Remember about setting bFullPath argument in compression methods to false.

### How to create an archive under Windows that will be readable under Linux/OS X?

Inside archives there is information stored about the system it was created under. It helps converting the file attributes that are stored inside the archive to file attributes that are used on the system on which the file is extracted. Some Linux archivers cannot convert Windows attributes to Linux, so that it is needed to create an archive with the Linux/OS X attributes already (and the internal info about the system set to the Linux value). To do it, simply call the CZipArchive::SetSystemCompatibility() method with the iSystemID argument set to ZipCompatibility::zcUnix. See also Unicode Support: Using Non-English Characters in Filenames, Comments and Passwords to read how to preserve filenames compatibility.

### How to extract or delete files that match a specified wildcard pattern?

You need to build a CZipIndexesArray object with the CZipArchive::FindMatches() method and then:
See Searching in Archive for more information.

### Why an exception is thrown when I call one of CZipArchive::CloseFile() methods?

If you haven't extracted file contents entirely (e.g. only the beginning) or you have encountered an exception during extraction, you need to call the CZipArchive::CloseFile(LPCTSTR, bool) with bAfterException parameter set to true.

### How to quickly detect if a file is a zip archive without reading a whole archive directory?

Use one of the static methods:

### How to create archives that are not extractable by other libraries?

The easiest way is to go to CZipFileHeader.cpp and CZipCentralDir.cpp and change values of the two first bytes in all m_gszSignature(...) fields. Keep the fields at the same size though. It is enough to change the first byte from 0x50 to e.g. 0x60. Just for the consistency update the same way CZipStorage::m_gszExtHeaderSignat.

### Will the ZipArchive Library work with .NET applications?

You can use the Library with a C++/CLI application. See Compilation of the ZipArchive Library and Integration with Applications for more information.
Article ID: faq