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

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

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 := 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; 

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!