c++builder  解压缩  TZCompressionStream  TZDecompressionStream

#include <System.ZLib.hpp>

 

void __fastcall TForm33::Button1Click(TObject *Sender)
{
    /* Create the Input, Output and Compressed streams. */
    TFileStream *input = new TFileStream(Edit1->Text, fmOpenRead);
    TFileStream *output = new TFileStream(Edit2->Text, fmCreate);
    TZCompressionStream *zip = new TZCompressionStream(output, zcDefault, 8);

    /* Compress data. */
    zip->CopyFrom(input, input->Size);

    /* Free the streams. */
    zip->Free();
    input->Free();
    output->Free();
}

// ---------------------------------------------------------------------------
void __fastcall TForm33::Button2Click(TObject *Sender)
{
    /* Create the Input, Output, and Decompressed streams. */
    TFileStream *input = new TFileStream(Edit2->Text, fmOpenRead);
    TFileStream *output = new TFileStream(ChangeFileExt(Edit1->Text, ""), fmCreate);
    TZDecompressionStream *unzip = new TZDecompressionStream(input);

    /* Decompress data. */
    output->CopyFrom(unzip, 0);

    /* Free the streams. */
    unzip->Free();
    input->Free();
    output->Free();
}

 

posted on 2015-07-14 16:57  lypzxy  阅读(568)  评论(0编辑  收藏  举报