delphi的VCLunzip组件使用总结

tools->library->library path 中加上VCLUnZip的路径然后uses
给你一个加密文件的函数,参数为文件名,路径
function ZipToFile(FileName:string;FileDir:string):boolean;
var
VCLUnZip1: TVCLUnZip;
begin
Result := False;
VCLUnZip1 := TVCLUnZip.Create(nil);
with VCLUnZip1 do
begin
ZipName := FileDir+FileName1;
ReadZip;
Destdir := 解压地址;
RecreateDirs := True;
FilesList.Add('*.*');
DoAll := True;
OverwriteMode := Always;
Password := ''; //加密密码1653
end;
VCLUnZip1.UnZip;
VCLUnZip1.Free;
Result := true;
end;

 

//=======================压缩文件======================================

if fileexists('D:\compress.zip') then  //如果压缩的文件存在则删除
   deletefile('D:\compress.zip');
 VCLZip1.FilesList.Clear;
 VCLZip1.FilesList.Add('D:\compress\RemObjects文档翻译\*.*');//选择要压缩的文件

//VCLZip1.ExcludeList.Add('D:\compress\RemObjects文档翻译\RemObjects文档翻译1_逆水寒提供.doc');//排除不要压缩的文件
 VCLZip1.FilesList.Add('D:\compress\SN.TXT');
 VCLZip1.FilesList.Add('D:\compress\WINXP服务详解.txt');
  VCLZip1.FilesList.Add('D:\compress\新建 文本文档.txt');
  VCLZip1.AddDirEntriesOnRecurse := true;
   //VCLZip1.Recurse:=true;//压缩子目录

  VCLZip1.RelativePaths := true;//压缩相对路径信息
  VCLZip1.ZipName := 'D:\compress.zip';//压缩的文件名
   //VCLZip1.RootDir:='D:\';
   //VCLZip1.StorePaths:=true;//在压缩的文件里面存储路径信息
  VCLZip1.MultiZipInfo.WriteDiskLabels := true;
  VCLZip1.MultiZipInfo.FirstBlockSize := 200000;
   //VCLZip1.DestDir:='D:\test';

 VCLZip1.Zip;//开始压缩
//========================解压文件================================

with VCLUnZip1 do
  begin
    if not busy then 
    begin
     ZipName := 'D:\compress.zip';//解压文件的名字
   //VCLUnZip1.RootDir:='D:\test\';

     DestDir := 'D:\test\';//解压后文件存放的路径
     DoAll := false;//是否解压全部的文件
     readzip;//读取压缩文件的信息例如压缩的文件数目

     RecreateDirs := true;//是否重建目录
     RetainAttributes := True;
     for i := 0 to count - 1 do//选择要解压的文件
     begin
       showmessage(inttostr(i) + '=' + fileName[i]);
       if not (i in [0..1]) then
       begin
         Selected[i] := true;

       end;
     end;
     UnZipSelected;//解压选择的文件
   //Unzip;//解压文件
   end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值