压缩指定路径MyZipDir下的文件夹b及b目录下的所有文件和文件b.txt
function ZipDir(zipMode:Integer;zipControl:TVCLZip;MyZipName,MyZipDir:string):Boolean;
  begin
    {压缩指定目录中的文件和文件夹,指定RootDir,否则连同指定目录本身一同压缩}
    Result:=False;
    try
      with zipControl do
      begin
        case zipMode of
          0:RootDir:='';   //指定压缩目录
          1:RootDir:=MyZipDir;
        end;
        OverwriteMode:=Always;//覆盖
        AddDirEntriesOnRecurse:=True;
        RelativePaths:=True;//相对路径
        Recurse:=True;//是否遍历
        RecreateDirs:=True;//创建目录
        StorePaths:=True;//保存路径,如RootDir不指定则保持完成路径(去除盘符外的,需要保持盘符路径设置StoreVolumes属性)
        ZipName:=MyZipName;
        FilesList.Add(MyZipDir+'\b\*.*');
        FilesList.Add(MyZipDir+'\b.txt');
        Zip;
        Result:=True;
      end;
    except
 
    end;
  end;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-06-10
  • 2021-07-24
猜你喜欢
  • 2021-06-02
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-06-20
  • 2022-12-23
相关资源
相似解决方案