Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

Create a Zip from Data in Memory

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries

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;
}



 

 

 

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

Mail Component · .NET Mail Component · XML Parser