Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
|
Create Zip Excluding Files Matching PatternsHow to create a .zip archive excluding (skipping) files that match a set of wildcarded patterns. Download: Chilkat Cocoa Objective-C Libraries NSMutableString *strOutput = [NSMutableString stringWithCapacity:1000]; CkoZip *zip = [[[CkoZip alloc] init] autorelease]; BOOL success; // Any string unlocks the component for the 1st 30-days. success = [zip UnlockComponent: @"Anything for 30-day trial"]; if (success != YES) { [strOutput appendString: zip.LastErrorText]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; return; } success = [zip NewZip: @"test.zip"]; if (success != YES) { [strOutput appendString: zip.LastErrorText]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; return; } // Create a string array object with our set of filename patterns // to be excluded: CkoStringArray *sa = [[[CkoStringArray alloc] init] autorelease]; [sa Append: @"*.bak"]; [sa Append: @"*.tmp"]; // Tell the zip object to use these exclusions: [zip SetExclusions: sa]; // Append a directory tree. The AppendFiles does // not read the file contents or append them to the zip // object in memory. It simply appends references // to the files so that when WriteZip (or WriteZipAndClose, // or WriteExe, etc.) is called, the files are compressed // and encrypted. BOOL recurse; recurse = YES; [zip AppendFiles: @"/temp/a/*" recurse: recurse]; success = [zip WriteZipAndClose]; if (success != YES) { [strOutput appendString: zip.LastErrorText]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; return; } [strOutput appendString: @"Zip Created!"]; [strOutput appendString: @"\n"]; self.mainTextField.stringValue = strOutput; |
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.