Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

 

Create a Zip from Data in Memory

Download Chilkat C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C++ Libraries for VC++ 6.0 / Win32

Demonstrates how to create a Zip from in-memory data.

// Visual C++ Zip Compression Example Source Code
// to create a Zip file from data in memory.
//

#include "stdafx.h"

#include <CkZip.h>
#include <CkZipEntry.h>
#include <CkString.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");

    // Initialize a new Zip object.
    zip.NewZip("myZip.zip");

    // Generate some text to be stored in the Zip.
    CkString s;
    int i;
    for (i=0; i<100; i++)
	{
	s.append("This data will be stored in a Zip file.\r\n");
	}
    // Append the data to the Zip object.
    // The entry object is returned and should be deleted by the application.
    CkZipEntry *entry = zip.AppendData("stringData.txt",(const unsigned char *)s.getString(),s.getNumChars());
    delete entry;

    zip.WriteZipAndClose(0);

    // Now let's re-open the Zip, modify the data, and rewrite the Zip.

    // Open the Zip.
    CkZip zip2;
    zip2.OpenZip("myZip.zip");

    // Get the data.
    CkZipEntry *entry2 = zip2.FirstEntry();
    CkString s2;
    entry2->InflateToString2(s2);

    // Replace all occurances of the string "data" with "text"
    s2.replaceAllOccurances("data","text");

    // Replace this Zip entry's data.
    entry2->ReplaceData(s2);
    delete entry2;
    
    // Save the Zip.
    zip2.WriteZipAndClose(0);

    return 0;
}



 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser