Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

Transition from Zip.AppendOneFileOrDir to Zip.AddFile

Provides instructions for replacing deprecated AppendOneFileOrDir method calls with AddFile.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
zip: HCkZip;
localFilePath: PWideChar;
saveExtraPath: Boolean;
entryObj: HCkZipEntry;
ze: HCkZipEntry;
index: Integer;

begin
success := False;

zip := CkZip_Create();

//  ...
//  ...
localFilePath := 'c:/someDir/example.dat';
saveExtraPath := False;

//  ------------------------------------------------------------------------
//  The AppendOneFileOrDir method is deprecated:

entryObj := CkZip_AppendOneFileOrDir(zip,localFilePath,saveExtraPath);
if (CkZip_getLastMethodSuccess(zip) = False) then
  begin
    Memo1.Lines.Add(CkZip__lastErrorText(zip));
    Exit;
  end;

//  ...
//  ...

CkZipEntry_Dispose(entryObj);

//  ------------------------------------------------------------------------
//  Do the equivalent using AddFile.

//  Instead of returning the zip entry object, we just return success/failure.
success := CkZip_AddFile(zip,localFilePath,saveExtraPath);
if (success = False) then
  begin
    Memo1.Lines.Add(CkZip__lastErrorText(zip));
    Exit;
  end;

//  Do the following if you need the zip entry object for what was just appended.
//  The newly appended entry is the last one.
ze := CkZipEntry_Create();
index := CkZip_getNumEntries(zip) - 1;
CkZip_EntryAt(zip,index,ze);

CkZip_Dispose(zip);
CkZipEntry_Dispose(ze);