Contents - Index


Using TVCLUnZip 

 

Basic procedure for programming the VCLUnZip component: 

 

If you simply wish to extract all files from a particular zip file it is as easy as just specifying the ZipName and DestDir properties and then call the UnZip method.  That's it.  If you wish to do more, the following pseudo example gives a very cursory overview of the kinds of  things you can do...  

  

MemoPad: TMemo; 

Unzipper: TVCLUnZip; 

NumUnzipped: Integer; 

 

USES ... VCLUnZIp, kpZipObj;  <-kpZipObj is needed if you use some of the defined types ...  

 

With Unzipper do 

begin 

ZipName := 'c:\test\Zipfile.zip'    // set the zip filename 

ReadZip;                           // open it and read its information 

// List filenames in zip file 

for i := 0 to Count-1 do 

MemoPad.Lines.Add( Filename[i] + #9 + Pathname[i] ); 

// extract some files  

// determine which files to unzip 

FilesList.Add( '*.cpp' );              // unzip all .cpp files 

FilesList.Add( 'myprog.exe' );   // unzip myprog.exe 

FilesList.Add( '?<0-9>*\*.h' );      // .h files, if 2nd letter of dir starts with digit only 

FilesList.Add( Filename[Count-1] );   // extract last entry in zipfile 

DoAll := False;                  // Don't unzip all files 

DestDir := 'c:\mydir'         // Set destination directory 

RecreateDirs := False;     // don't recreate directory structures 

RetainAttributes := True   // Set attributes to original after unzipping  

NumUnzipped := Unzip;                        // Extract files, return value is the number of files actually unzipped 

end;