将整个目录添加到TKaZip

时间:2012-10-24 03:30:19

标签: delphi delphi-7

我刚开始使用TKaZip for Delphi7我可以锻炼如何构建和添加单个文件以压缩到.kmz文件但我仍然坚持如何将选定的目录压缩为.kmz文件。

这是我到目前为止所得到的

var
  FS: TFileStream;
  KaZip:TKaZip;
  KmzFileName:TFileName;
  aFileName : string;
  savedata : string;
begin

    savedata :='C:\Users\Puser\Desktop\testfolder\';

   //building .kmz for test
  aFileName := 'TEST';
  KmzFileName := ChangeFileExt(aFileName, '.kmz');
  KaZip := TKaZip.Create(nil);
  try
    // create an empty zipfile with .kmz extension:
    FS := TFileStream.Create(KmzFileName, fmOpenReadWrite or FmCreate);
    try
      KaZip.CreateZip(FS);
    finally
      FS.Free;
    end;
            //now sending files to .kmz
    KaZip.Open(KmzFileName); // Open the new .kmz zipfile
    KaZip.AddFilesAndFolders(savedata);
    KaZip.Close;

  finally
    KaZip.Free;

  end;

原始来源是Creating Compressed (Zipped) Folder using Delphi

0 个答案:

没有答案