example from project…
zip file
1 2 3 4 5 6 7 8 9 10 11 12 |
//packing in zip z := TZipFile.Create; FfilepathZIP := clientTempDir + '\' + TPath.GetRandomFileName + '.zip'; if (TFile.Exists(FfilepathZIP)) then TFile.Delete(FfilepathZIP); z.Open(FfilepathZIP, zmWrite); try z.Add(Ffilepath); z.Close(); finally z.Free; end; |
unzip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// unzip z := TZipFile.Create; try z.Open(filenameZIP, zmRead); if not TDirectory.Exists(clientTempDir) then TDirectory.CreateDirectory(clientTempDir); for i := 0 to z.FileCount - 1 do begin filename := z.FileName[i]; // having only one file in archive z.Extract(filename, clientTempDir, true); end; finally z.Free; end; |