Unzipper: extract specific file(s) from directory embedded within ZIP lazarus / 21-General ---------------------------------------------------------------------- Doug22 · 2021-11-06 11:40 Using TUnzipper, one can extract specific files from a ZIP archive by storing their names in FileList: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure UnZipFiles(FileList : TStrings); This works fine for files in the "root directory" of the archive, but I could not find a way to extract specific files when they are embedded in a directory structure within the ZIP. Example - suppose I want to extract file4.txt from a ZIP archive with the following internal structure: file1.txtfile2.txtdirectory1\file3.txtdirectory1\file4.txtdirectory2\f ile5.txt... I tried variations in FileList around 'directory1\file4.txt', but nothing got extracted. However, the UnZipAllFiles procedure extracted everything as expected, no problems. Am I using the incorrect input for FileList, or have I bumped into a limitation of UnZipper? (Windows 10 OS, FPC 3.2.0) ---------------------------------------------------------------------- wp · 2021-11-06 11:45 Try a forward slash as directory separator, even if you are on Windows. ---------------------------------------------------------------------- Renat.Su · 2021-11-06 14:19 Look at this gist https://gist.github.com/Al- Muhandis/e9edd46c861622e547d86320174b8e88 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure UnzipODT(const aUnzipDir, aZipFile: String);var  aUnZipper: TUnZipper;begin  aUnZipper:=TUnZipper.Create;  try    ForceDirectories(aUnzipDir);    aUnZipper.OutputPath:=aUnzipDir;    aUnZipper.UnZipAllFiles(aZipFile);  finally    aUnZipper.Free;  end;end; procedure ZipODT(const aSrcDir, aZipFile: String);var  aZipper: TZipper;  aList: tStringList;  s: String;begin  aZipper := TZipper.create;  aList := TStringList.create;  try    FindAllFiles(aList, aSrcDir);    aZipper.FileName := aZipFile;    for s in aList do      aZipper.Entries.AddFileEntry(s, ExtractRelativePath(aSrcDir, s));    aZipper.ZipAllFiles;  finally    aZipper.Free;    aList.free;  end;end; ---------------------------------------------------------------------- Renat.Su · 2021-11-06 14:21 Ah, I'm sorry, I didn't fully read the problem ---------------------------------------------------------------------- Doug22 · 2021-11-06 14:49 Thanks, wp, and Renat.su, for replying so promptly to my question. The correction provided by wp worked as desired. That is, using 'directory1/file4.txt' (regular slash) as an entry in FileList extracted the desired file, creating 'directory1' with file4.txt in it. (Amusingly listed by Windows, of course, as 'directory1\file4.txt'.) Microsoft's use of backslash vs. regular slash was clearly a bad idea. Doug