开发者

How am I supposed to use JEDI's JCLCompression to create a 7z archive?

I am trying to create a 7z archive of certain files using Delphi 2009.

The code below seems to work, but all of the items in the resulting 7z file are of zero size. All of the file names that are in the archive are correct, but they shouldn't be zero size.

How can I add files properly to a 7z archive using JCLCompression?

var
  fname, archiveFileName: string;
  arch: TJclUpdateArchive;
  archiveclass: TJCLUpdateArchiveClass;
  sr: TSearchRec;
begin
  fname := GetDesktop + 'Support.7z';

  archiveclass := GetArchiveF开发者_StackOverflow中文版ormats.FindUpdateFormat(fname);

  if not Assigned(archiveclass) then
    raise Exception.Create('Could not determine the Format of ' + fname);

  arch := archiveclass.Create(fname);
  try
    with arch do
    begin

      if FindFirst(uFolder + '*.*', faAnyFile, sr) = 0 then
      begin
        repeat
          AddFile(ExtractFileName(sr.Name), sr.Name);
        until FindNext(sr) <> 0;

        FindClose(sr);
      end;

      Compress;
    end;
  finally
    arch.free;
  end;
end;


Never, ever, having jused JCLCompression my answer may wel be totally wrong, but don't you have to specify the folder somewhere ? You are only adding the filenames.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜