Extracts a file from a zip file into a variable.

Syntax

Data = SRP_Zip("ExtractFile", ZipHandle, Index)

Returns

The extracted file's data, or "" if the file was empty or if there was an error.

Parameters

NameDescription
ZipHandleHandle to an opened zip file.
IndexIndex of the file to extract.

Remarks

Call this service to extract a file into a variable. The value of Index can the value returned by FindFile or the same index used to reference the file in the value returned by GetFileList.

Examples

// Extract all files and save to a table (assuming table was previously opened)
hZip = SRP_Zip("Open", "C:\MyFile.zip")
If hZip EQ 0 then
   Call Msg(@Window, SRP_Zip("GetLastError"))
end else
   FileList = SRP_Zip("GetFileList", hZip)
   NumFiles = DCount(FileList, @FM)
   For i = 1 to NumFiles
       Data = SRP_Zip("ExtractFile", hZip, i)
       Write Data to hTable, FileList<i> then NULL
   Next i
   SRP_Zip("Close", hZip)
end
// Extract and save a single known file to a table (assuming table was previously opened)
hZip = SRP_Zip("Open", "C:\MyFile.zip")
If hZip EQ 0 then
   Call Msg(@Window, SRP_Zip("GetLastError"))
end else
   FileIndex = SRP_Zip("FindFile", hZip, "MyImage.bmp")
   If FileIndex NE 0 then
       Data = SRP_Zip("ExtractFile", hZip, FileIndex)
       Write Data to hTable, "MyImage.BMP" then NULL
   end
   SRP_Zip("Close", hZip)
end
  • No labels