I am trying to create a 7z archive of specific files using Delphi 2009.
Below is the code below, but all elements in the resulting 7z file are of zero size. All file names that are in the archive are correct, but they should not be of zero size.
How can I correctly add files to the 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;
source share