• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi解压缩ZipForge

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

 

ZipForge

http://www.componentace.com/zip_component_zip_delphi_zipforge.htm

downLoad

http://www.componentace.com/download/download.php?editionid=12

Example

http://www.componentace.com/zip-delphi.htm

这个压缩是通用的,其他压缩软件能打开。

procedure TFrmMain.myzipZF(ainFile,aoutFile:string);
var
ms:tmemorystream;
begin
  ms := tmemorystream.Create;
  ms.LoadFromFile(ainFile);
  self.ZipForge1.FileName :=aoutFile;
  self.ZipForge1.OpenArchive;
  self.ZipForge1.AddFromStream(system.IOUtils.TPath.GetFileName(ainFile),ms,true );
  self.ZipForge1.CloseArchive;
  ms.Free;
end;
proced

 

c++builder、Delphi 压缩文件

ZipForge is a fast and powerful VCL Zip component, written in Delphi.
It lets you easily create ZIP archives, extract files from zip files to hard drive or memory, add files to a zip archive from disk or memory, replace, move and delete files in zip archives. Also it creates and reads self-extracting (SFX) zip archives, AES encrypted and multi-volume zip files.

ZipForge main features:

    • Opens and creates archives encrypted with strong AES encryption algorithm
    • Zip64 supports - lets you create ZIP files over 4 GB
    • Unicode file names support
    • Includes transaction system which allows you to rollback changes if archive update failed
    • Adds compressed data directly from streams and extracts archived files to streams without creating temp files
    • Lets you store full path with drive for each file
    • Allows to search for files inside archive by mask
    • Progress indication
    • Full Delphi source code is available 

       

zf: TZipForge;
zf := TZipForge.Create(nil);
zf.OpenArchive(aInStream, False);
zf.ExtractToStream(FileName, StreamOut);

     

    var Zip:=TZipForge.Create(nil);
        zip.FileName:=modulepath+'temp\'+self.filename;
        zip.OpenArchive(fmOpenRead);
        zip.BaseDir:= modulepath+'temp\';
        zip.ExtractFiles('*.*');
        zip.CloseArchive;
        zip.Free;

setup Path

D:\Program Files (x86)\ComponentAce\ZipForge

压缩文件

void __fastcall TForm4::Button1Click( TObject * Sender )
{
    TMemoryStream * ms = new TMemoryStream( );
    Memo1->Text="Hello Word!";
    Memo1->Lines->SaveToStream( ms );
    ZipForge1->FileName = "a.zip";//压缩包的名称
    ZipForge1->OpenArchive( );
   ZipForge1->AddFromStream( "a.txt", ms, true );//压缩包里的文件
    //ZipForge1->AddFromString("b.txt","text2",)
    ZipForge1->CloseArchive( );
    delete ms;

}

解压缩

void __fastcall TForm4::Button2Click( TObject * Sender )
{
    TMemoryStream * ms = new TMemoryStream( );
    ZipForge1->FileName = "a.zip";//压缩包名称
    ZipForge1->OpenArchive( );
    ZipForge1->ExtractToStream( "a.txt", ms );//压缩包里的文件
    ms->Position = 0;
    Memo1->Lines->LoadFromStream( ms );

    // To String
//    String StrOut;
//    ZipForge1->ExtractToString( "a.txt", StrOut );
    ZipForge1->CloseArchive( );
    delete ms;
}

 

解压缩到字符串

void __fastcall TForm4::Button2Click( TObject * Sender )
{

    ZipForge1->FileName = "a.zip";
    ZipForge1->OpenArchive( );
    // To String
    String StrOut;
    ZipForge1->ExtractToString( "a.txt", StrOut );
    Memo1->Text = StrOut;
    ZipForge1->CloseArchive( );
}

查找压缩包文件列表,找到文件名称,然后

ZipForge1->ExtractToStream(文件名,stream);

Use FindFirst and FindNext methods of TZipForgefor searching files within the archive file. 

获得压缩包中的文件列表

    TZFArchiveItem afItem;
    bool aFound = ZipForge1->FindFirst( "*.*", afItem, faAnyFile, "" );
    while ( aFound )
    {
        this->mmoFileList->Lines->Add( afItem.FileName );
        aFound = ZipForge1->FindNext( afItem );
    }

压缩包文件详情

        this->mmoFileList->Lines->Add( afItem.FileName );
        this->mmoFileList->Lines->Add( ">>>>" );
        this->mmoFileList->Lines->Add( afItem.StoredPath );
        this->mmoFileList->Lines->Add( afItem.CompressedSize );//压缩后文件大小
        this->mmoFileList->Lines->Add( afItem.UncompressedSize );//压缩前文件大小
        this->mmoFileList->Lines->Add( afItem.CompressionRate );
        this->mmoFileList->Lines->Add((int) afItem.Encrypted );
        this->mmoFileList->Lines->Add( afItem.LastModFileDate );
        this->mmoFileList->Lines->Add( afItem.LastModFileTime );
        this->mmoFileList->Lines->Add( afItem.CRC );
        this->mmoFileList->Lines->Add( afItem.ExternalFileAttributes );
        this->mmoFileList->Lines->Add( afItem.Comment );

 

 从流中解压

    TMemoryStream * ms;
    ms = new TMemoryStream( );
    ms->LoadFromFile( "a.zip" );
    ZipForge1->OpenArchive( ms, false );

 

 

.Net c#

ICSharpCode.SharpZipLib.dll

ZipOutputStream

http://icsharpcode.github.io/SharpZipLib/

 

自带zip 

var zip:TZipFile;//压缩文件
ss:tstringstream;
begin
ss:=tstringstream.Create('hello');
zip:=tzipfile.Create;
zip.Open('aa.zip',zmwrite);
zip.Add(ss,'com.txt');
zip.Close;
zip.Free;
ss.Free;

解压文件

var zip := TZipFile.Create;
zip.Open('aa.zip',zmRead);
self.Caption:=zip.FileName[0];
zip.ExtractAll();
zip.Close;
zip.Free;

大文件200M的怎么等解压完再结束,

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Delphi【BASM】使用Delphi的BASM发布时间:2022-07-18
下一篇:
最简单的Delphi程序(控制台)发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap