Post by JR Nicolet on Feb 21, 2004 13:18:50 GMT -5
Hello - I am trying to get VCPZip to work in an ISAPI application (D7).
One of the last statement in the code below (Marked <<<-- ) causes an error indicating that the files is being used by another application, even under debugging conditions...
The app is expected to respond to clients connecting over internet. Each time, it should collect a number of files, zip them all on the fly and stream the resulting archive to the client's machine.
I am very new to VCPzip (I tried a couple of years ago but then had to work on another project until now)
What am I doing wrong?
JR Nicolet
Code extract:
==========================
FS: TFileStream;
ZippedFile := 'C:\testfile.zip';
FS := TFileStream.Create(ZippedFile,fmCreate); // open the filestream before writing to it
VCLZip1.ZipName := ZippedFile; // Assign filename to Zip component
VCLZip1.Recurse := False; // do NOT go into subdirectories
VCLZip1.StorePaths := False; //* Don't Keep path information */
VCLZip1.PackLevel := 9; //* Highest level of compression */
iZipCount := 0; // initialize
FOP loop // used to cycle through a collection of files to be compressed
...
sSelectedFile := ... here, code to locate a file
VCLZip1.FilesList.Add(sSelectedFile);
iZipCount := iZipCount + 1 ; // increment our count
...
END FOR Loop
iCountOfZippedFiles := VCLZip1.Zip; // PERFORM ACTUAL ZIPPING
FS := TFileStream.Create(ZippedFile,fmOpenRead); <<<<-- causes an error
try
Response.ContentType := 'application/zip';
Response.SetCustomHeader('Content-Disposition', 'filename=' +
ExtractFilename(ZippedFile));
Response.ContentStream := FS;
Response.SendResponse;
Handled := True;
finally
FS.Free;
end; // try
==========================
One of the last statement in the code below (Marked <<<-- ) causes an error indicating that the files is being used by another application, even under debugging conditions...
The app is expected to respond to clients connecting over internet. Each time, it should collect a number of files, zip them all on the fly and stream the resulting archive to the client's machine.
I am very new to VCPzip (I tried a couple of years ago but then had to work on another project until now)
What am I doing wrong?
JR Nicolet
Code extract:
==========================
FS: TFileStream;
ZippedFile := 'C:\testfile.zip';
FS := TFileStream.Create(ZippedFile,fmCreate); // open the filestream before writing to it
VCLZip1.ZipName := ZippedFile; // Assign filename to Zip component
VCLZip1.Recurse := False; // do NOT go into subdirectories
VCLZip1.StorePaths := False; //* Don't Keep path information */
VCLZip1.PackLevel := 9; //* Highest level of compression */
iZipCount := 0; // initialize
FOP loop // used to cycle through a collection of files to be compressed
...
sSelectedFile := ... here, code to locate a file
VCLZip1.FilesList.Add(sSelectedFile);
iZipCount := iZipCount + 1 ; // increment our count
...
END FOR Loop
iCountOfZippedFiles := VCLZip1.Zip; // PERFORM ACTUAL ZIPPING
FS := TFileStream.Create(ZippedFile,fmOpenRead); <<<<-- causes an error
try
Response.ContentType := 'application/zip';
Response.SetCustomHeader('Content-Disposition', 'filename=' +
ExtractFilename(ZippedFile));
Response.ContentStream := FS;
Response.SendResponse;
Handled := True;
finally
FS.Free;
end; // try
==========================