我应该如何使用JEDI的JCLCompression创建7z归档文件? [英] How am I supposed to use JEDI's JCLCompression to create a 7z archive?

查看:85
本文介绍了我应该如何使用JEDI的JCLCompression创建7z归档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Delphi 2009创建某些文件的7z存档。

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

以下代码似乎可以正常工作,但是生成的7z文件中的所有项目大小为零。存档中的所有文件名称都是正确的,但大小不能为零。

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.

如何正确添加文件

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

  archiveclass := GetArchiveFormats.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;


推荐答案

从来没有,曾经判决过JCLCompression,我的回答可能很高兴是完全错误的,但是您不必在某个地方指定文件夹吗?您只添加文件名。

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.

这篇关于我应该如何使用JEDI的JCLCompression创建7z归档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆