I want to replace the file (= delete the old and add a new one) to the zip archive using the standard element System.Zip Delphi XE2 / XE3. But there are no replacement / removal methods. Does anyone know how this could be achieved without having to extract all the files and add them to the new archive?
I have this code, but it adds "document.txt" again if it is already present:
var ZipFile: TZipFile; SS: TStringStream; const ZipDocument = 'E:\document.zip'; begin ZipFile := TZipFile.Create; //Zipfile: TZipFile SS := TStringStream.Create('hello'); try if FileExists(ZipDocument) then ZipFile.Open(ZipDocument, zmReadWrite) else ZipFile.Open(ZipDocument, zmWrite); ZipFile.Add(SS, 'document.txt'); ZipFile.Close; finally SS.Free; ZipFile.Free; end; end;
Note. I used to use TPAbbrevia (this did the job), but now I would like to use the Delphi Zip module. Therefore, please do not respond to something like "use another library." Thanks.
delphi zip delphi-xe3 delphi-xe2
oxo
source share