[delphizip] Re: Extract question

  • From: Roger Aelbrecht <Roger.Aelbrecht@xxxxxxxxx>
  • To: delphizip@xxxxxxxxxxxxx
  • Date: Thu, 10 Jan 2008 19:59:36 +0100

Uli Brueggemann wrote:
> Hi,
> please may I ask a simple question?
> 
> I have a zip file with 2 files in a subfolder, e.g. \tmp\x1 and \tmpx2. The
> zip file may have also other or more files. So I want to find the two files
> x1 and x2 if they are in the zip file and extract them.
> 
> If I specify only ZipMaster1.FSpecArgs.Add('x1') and
> ZipMaster1.FSpecArgs.Add('x2') then
> with Extract nothing is extracted (as the files are in a subfolder).
> 
> With e.g. ZipMaster1.FSpecArgs.Add('\temp\x1') also nothing is extracted.
> But I also do not necessarily know the subfolder name.
> 
> With ZipMaster1.FSpecArgs.Add('*.*') both files are extracted but also other
> undesired files.
> 
> Now I want first to search if e.g. x2 exists in the zip-file and if yes then
> extract x2.
> 
> How to do it?
> I do not really understand ExtrBaseDir, RootDir ... Also I do not understand
> how to handle idx and result of function ZipMaster1.Find.
> 
> I only want to extract the files x1, x2. No directory needed and desired.
> 
> Thanks for your kind help.
> 
> Best
> 
> Uli Brueggemann
> 
> 
> -----------
> To unsubscribe from this list, send an empty e-mail 
> message to:
>   delphizip-request@xxxxxxxxxxxxx 
> and put the word unsubscribe in the subject.
> 
> 

All depends on how the filenames are stored in the archive when it is 
created.
If a full path name is used then the full path needs to be used in
ZipMaster1.FSpecArgs to extract one single file.

If you don't know the exact name you can browse trough the content of 
the archive using the DirEntry property.

Start setting the filename in ZipMaster1.ZipFileName
When the filename is set ZipMaster will open the archive and read the 
content.
Now you can loop through such as
// read filenames
        for i:=0 to ZipMaster1.Count-1 do
            FileName := ZipMaster1.DirEntry[i]^.Filename;

Now you can test if FileName is the one you need and at the same time 
you have the correct spelling and you can do

ZipMaster1.FSpecArgs.Add(ZipMaster1.DirEntry[i]^.Filename);

Then you can do the extract

HTH

-- 
Roger Aelbrecht


-----------
To unsubscribe from this list, send an empty e-mail 
message to:
  delphizip-request@xxxxxxxxxxxxx 
and put the word unsubscribe in the subject.

Other related posts: