Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create a Zip While Excluding Files Matching a Pattern
Demonstrates how to create a Zip while excluding files matching a pattern. // Zip Compression C++ Source Code to
// add an entire directory tree to a Zip
// while excluding files matching a pattern.
//
#include "stdafx.h"
#include "CkZip.h"
#include "CkZipEntry.h"
#include "CkStringArray.h"
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Unlock the Zip product.
// This only needs to be done once when the first CkZip object
// is instantiated.
CkZip zip;
zip.UnlockComponent("unlockCode");
// Create a new Zip and append files and directories recursively.
zip.NewZip("myZip.zip");
// Exclude all of these types of files.
CkStringArray sArray;
sArray.Append("*.obj");
sArray.Append("*.exe");
sArray.Append("*.ncb");
sArray.Append("*.db");
// Add the exlusions.
zip.SetExclusions(&sArray);
// Also exclude directories named "Sounds", "Debug" and "Release", wherever found.
zip.ExcludeDir("Debug");
zip.ExcludeDir("Release");
zip.ExcludeDir("Sounds");
// Append the files, excluding everything we've specified.
zip.AppendFiles("./Tree/*",true,0);
zip.WriteZipAndClose(0);
return 0;
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.