![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Android™) Recursively Add Files to a ZIP Using AppendFilesExSee more Zip Examples
This example demonstrates how to use the The example:
The This method is cross-platform and works on Windows, macOS, Linux, Android, iOS, and other supported operating systems. Some arguments are Windows-specific:
On non-Windows operating systems, these Windows-specific options are simply ignored. Suppose the local filesystem contains the following directory tree: c:/project/files/docs/readme.txt And suppose the following call is made:
If project/files/docs/readme.txt In this case, the extra leading path information from the filePattern is preserved in the ZIP.
If docs/readme.txt
In this case, the leading Note: This example requires Chilkat v11.0.0 or greater.
// Important: Don't forget to include the call to System.loadLibrary // as shown at the bottom of this code sample. package com.test; import android.app.Activity; import com.chilkatsoft.*; import android.widget.TextView; import android.os.Bundle; public class SimpleActivity extends Activity { private static final String TAG = "Chilkat"; // Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean success = false; CkZip zip = new CkZip(); success = zip.NewZip("appendFilesEx.zip"); if (success == false) { Log.i(TAG, zip.lastErrorText()); return; } // Recursively include all files beneath c:/project/files. boolean recurse = true; // // The saveExtraPath argument controls whether the extra leading path // information from the filePattern is included in the stored ZIP paths. // // For example, suppose the local filesystem contains: // // c:/project/files/docs/readme.txt // c:/project/files/docs/manual.pdf // c:/project/files/images/logo.png // // And suppose AppendFilesEx is called with: // // "c:/project/files" // // If saveExtraPath = true, the ZIP stores: // // project/files/docs/readme.txt // project/files/docs/manual.pdf // project/files/images/logo.png // // In this case, the extra path information from the filePattern is preserved. // // ---------------------------------------------------------------- // // If saveExtraPath = false, the ZIP stores paths relative to the // directory specified by the filePattern: // // docs/readme.txt // docs/manual.pdf // images/logo.png // // In this case, the leading "project/files" path is not stored in the ZIP. // ---------------------------------------------------------------- // Preserve extra path information within the ZIP archive. boolean saveExtraPath = true; // Do not require the Windows archive attribute. boolean archiveOnly = false; // Include hidden files. boolean includeHidden = true; // Exclude files having the Windows System attribute. boolean includeSystem = false; success = zip.AppendFilesEx("c:/project/files",recurse,saveExtraPath,archiveOnly,includeHidden,includeSystem); if (success == false) { Log.i(TAG, zip.lastErrorText()); return; } // Write the ZIP archive to disk. success = zip.WriteZipAndClose(); if (success == false) { Log.i(TAG, zip.lastErrorText()); return; } Log.i(TAG, "ZIP archive created successfully."); } static { System.loadLibrary("chilkat"); // Note: If the incorrect library name is passed to System.loadLibrary, // then you will see the following error message at application startup: //"The application <your-application-name> has stopped unexpectedly. Please try again." } } |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.