|
Post by iamimpressed on Nov 21, 2004 1:15:14 GMT -5
I have a zip file which contains zip files. I would like to unzip the zipfile from the ArchiveSteam, but do not see how this can be done.
|
|
|
Post by Kevin on Nov 22, 2004 8:03:01 GMT -5
You can use the ArchiveStream property to hold archives in TMemoryStreams while working with them. Then you just call UnZip as usual.
Kevin
|
|
|
Post by iamimpressed on Nov 23, 2004 0:32:05 GMT -5
kevin, I think I understand what's said, but I seem to loose the archive. ArchiveIsStream becomes false.
What I have is a zip of zipped invoices over a range of dates. When I find an invoice in the date range, I want to unzip this zip. A snap of code is as below:
if fileexists(fname) then begin ISPunzip := tvclunzip.Create(nil); try ISPunzip.ArchiveStream := TmemoryStream.Create; ISPunzip.ZipName:=fname; ISPunzip.ReadZip; number2do:=ISPunzip.Count; for ii:=0 to (number2do-1) do begin inzname:=ISPunzip.Filename[ii]; inzdate:=DateTimeToStDate(ISPunzip.DateTime[ii]); if (inzdate>sdate) and (inzdate<edate) then begin LogMsg('file has ['+inzname+']'); //ArchiveIsStream: Boolean? ISPunzip.UnZip; end; end; except begin ispunzip.Free; exit; end; end; end;
I am using version 2.23
|
|
|
Post by Kevin on Nov 23, 2004 7:59:00 GMT -5
Rather than setting ZipName, you should use ArchiveStream.LoadFromFile in this case. Setting ZipName causes VCLZip to revert back to using files.
Kevin
|
|
|
Post by iamimpressed on Nov 27, 2004 14:13:29 GMT -5
Thanks Kevin, I have the code working using the following steps:
I had to create a stream (ISPInzArchive) and LoadFromFile.
Then create a unzip and set its archivestream = to stream (ISPInzArchive). [[setting ZipName disables archivestream]]
I can now UnZipToStream (ISPInvfile) the desired files. [[you must specify the original path with file name]]
creating a second unzip (DCunzip) and setting it's archivestream to second stream (ISPInvfile). I had to set DoAll to true or use FilesList.Add(name). [[This is contraire to the Help file]]
The DCunzip.UnZip method can be called to save the invoice file to disk.
|
|
|
Post by Kevin on Nov 29, 2004 9:39:17 GMT -5
>>I have the code working using the following steps: ...snip... << Good! >>I can now UnZipToStream (ISPInvfile) the desired files. [[you must specify the original path with file name]] << That is true. >>creating a second unzip (DCunzip) and setting it's archivestream to second stream (ISPInvfile). I had to set DoAll to true or use FilesList.Add(name). [[This is contraire to the Help file]] << I'm not sure how you mean? >>The DCunzip.UnZip method can be called to save the invoice file to disk. << Very good!! Kevin
|
|
|
Post by iamimpressed on Nov 30, 2004 8:33:38 GMT -5
In the help file on FileList Property it states: Also, if FilesList is empty when calling UnZip all files will be extracted, even if DoALL is not set to True.
I found that DoALL had to be set True for UnZip to work.
|
|
|
Post by Kevin on Nov 30, 2004 10:07:08 GMT -5
OK, thanks! I'll check on that.
Kevin
|
|