Recent

Author Topic: Zip File, Extract folder and subfolders  (Read 12195 times)

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Zip File, Extract folder and subfolders
« Reply #15 on: February 18, 2016, 05:00:35 pm »
Yes this is what I'm trying to do now.
I will see if it's gonna work
O, yeah, another method is just looping through all the files yourself and extracting all that begins with you path.

Like this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   AbUnZipper: TAbUnzipper;
  4.   i : Integer;
  5. begin
  6.   AbUnZipper := TAbUnzipper.Create(nil);
  7.   try
  8.     ForceDirectories('c:\temp\t4');
  9.     AbUnZipper.BaseDirectory := 'c:\temp\t4';
  10.     AbUnZipper.FileName := 'c:\temp\test.zip';
  11.     AbUnZipper.ExtractOptions := [eoCreateDirs, eoRestorePath];
  12.     //AbUnZipper.ExtractFiles('tpabbrevia\*.*'); // <-- doesn't work on sub-subfolders
  13.  
  14.     for i := 0 to pred(AbUnZipper.Count) do
  15.       if Pos(uppercase('tpabbrevia/'), uppercase(AbUnZipper.Items[i].Filename)) = 1 then
  16.         AbUnZipper.ExtractAt(i, '');
  17.  
  18.     ShowMessage('done');
  19.   finally
  20.     AbUnZipper.Free;
  21.   end;
  22. end;

It's like how Abbrevia does it in TAbArchive.ExtractFilesEx(). Do note the forward slash after the path-name. Internally a zip normally has forward slashes so you need to check path/ as beginning of the filename.

(Above example works for me)

anis2505

  • Full Member
  • ***
  • Posts: 201
Re: Zip File, Extract folder and subfolders
« Reply #16 on: February 19, 2016, 06:44:30 pm »
Hi,

Thank you  :D.
I managed to make it work for Abtreeview too.

I post the attached for anyone interested in the future

regards
Dear Confucius you said {A picture is worth a thousand words}
I say {a good example is worth a thousand words}

 

TinyPortal © 2005-2018