压缩指定路径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+'*.*'); FilesList.Add(MyZipDir+'.txt'); Zip; Result:=True; end; except end; end;