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

 

 

 

 

 

 

 

 

WriteToMemory / OpenFromMemory

Writing a .zip to memory, opening a .zip from 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

void ChilkatSample(void)
    {
    //  
// Write a zip to memory, open a zip from memory...

    CkZip zip;

    bool success;

    //  Any string unlocks the component for the 1st 30-days.
    success = zip.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("%s\n",zip.lastErrorText());
        return;
    }

    // Initialize the zip object:
    zip.NewZip("unused.zip");

    // Append a directory tree:
    bool recurse = true;
    success = zip.AppendFiles("c:/temp/abc123/*",recurse);
    if (success != true) {
        printf("%s\n",zip.lastErrorText());
        return;
    }

    // Write an image of the .zip file into memory.
    // (Normally you might call zip.WriteZipAndClose() to write the zip to the filename
    // previously specified in the NewZip call.)
    CkByteData zipInMemory;
    success = zip.WriteToMemory(zipInMemory);
    if (success != true) {
        printf("%s\n",zip.lastErrorText());
        return;
    }

    
    // Access the raw bytes of the zip in memory:
    const unsigned char *zipImage = zipInMemory.getBytes();
    unsigned long zipSize = zipInMemory.getSize();

    // Save to a .zip file:
    zipInMemory.saveFile("test.zip");


    // Open the .zip directly from memory:
    CkZip zip2;
    success = zip2.OpenFromMemory(zipImage,zipSize);
    if (success != true) {
        printf("%s\n",zip2.lastErrorText());
        return;
    }

    // Unzip:
    int unzipCount = zip2.Unzip("c:/temp/zipTestingDir");
    if (unzipCount < 0) {
        printf("%s\n",zip2.lastErrorText());
        return;
    }

    }

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