Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Zip a Directory Tree
Very simple example showing how to Zip a directory tree. // Visual C++ Example Source Code to create a Zip file
//
#include "stdafx.h"
#include "CkZip.h"
#include "CkZipEntry.h"
void testCreateZip(void)
{
// Unlock the Zip product.
// This only needs to be done once when the first CkZip object
// is instantiated. Any string automatically starts a fully-functional
// 30-day trial.
CkZip zip;
bool success = zip.UnlockComponent("Anything for 30-day trial.");
if (!success)
{
printf("%s\n",zip.lastErrorText());
return;
}
// Create a new Zip and append files and directories recursively.
zip.NewZip("myZip.zip");
success = zip.AppendFiles("./Tree/*",true,0);
if (!success)
{
printf("%s\n",zip.lastErrorText());
return;
}
success = zip.WriteZipAndClose(0);
if (!success)
{
printf("%s\n",zip.lastErrorText());
return;
}
// Memory Leaks? See CkSettings for more information about how
// many C++ programmers mistakenly think there are memory leaks.
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
testCreateZip();
return 0;
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.