ArchiveReader locking up file?
I generate 5 reports, merge them to 1 file and view them with the
ArchiveReader. After the print command I would like to delete the archive
file but it is kept locked. I have tried the reset function but this
doesn't help.
This is part of the code:
Merger1.Execute;
ppArchiveReader1.ArchiveFileName := ExtractFilePath(Application.ExeName)
+ '\userdata\' + IntToStr(DM.User.ID) + '\result.raf';
ppArchiveReader1.Print;
ppArchiveReader1.Reset;
DeleteFile(ExtractFilePath(Application.ExeName) + '\userdata\' +
IntToStr(DM.User.ID) + '\result.raf');
How can I delete the file?
Thanks in advance,
Stijn Verrept.
ArchiveReader. After the print command I would like to delete the archive
file but it is kept locked. I have tried the reset function but this
doesn't help.
This is part of the code:
Merger1.Execute;
ppArchiveReader1.ArchiveFileName := ExtractFilePath(Application.ExeName)
+ '\userdata\' + IntToStr(DM.User.ID) + '\result.raf';
ppArchiveReader1.Print;
ppArchiveReader1.Reset;
DeleteFile(ExtractFilePath(Application.ExeName) + '\userdata\' +
IntToStr(DM.User.ID) + '\result.raf');
How can I delete the file?
Thanks in advance,
Stijn Verrept.
This discussion has been closed.
Comments
I had the same problem, it is because the file is closed
when the archivereader object is destroyed (see ppArchiv.pas).
So what you can do is to create and destroy the ppArchiveReader
object yourself. I have made a archivestreamreader which reads
an archive from a stream, so you won't actually need to save the
file to disk, if you want it just let me know.
greetings,
Rob
Thanks for the offer. Well I just quickly create & destroy it now
Can I have the archivestreamreader component?
Appreciate your help.
Please email it to vikram@captools.com
Vikram
I had another question : How do write an archive output to a stream instead
of the raf file? I could find any option in the TppREport component to write
to an archive stream..?
Thanks in advance
Vikram
Tech Tip: Loading an Archive File to a Blob
(or memory stream)
---------------------------------------------------
You can easily write a routine to take a .RAF file and
load it into a blob field or a TMemoryStream:
myFileStream := TFileStream.Create('myArhcive.RAF', fmOpenRead);
myFileStream.Position := 0;
myBlobField.LoadFromStream(myFileStream);
myFileStream.Free;
OR
myMemoryStream := TMemoryStream.Create;
{note: passing 0 as the second parameter will copy the entire stream}
myMemoryStream.CopyFrom(myFileStream, 0);
myMemoryStream.Free;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Unfortunately there is no way to print an archive file to a stream. You
will need to save the file, then either load it into memory, or blob stream
and perhaps delete the file.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
indicate how hard it is?
I need to generate separate reports in memory and combine them later on.
Thanks
Vikram
You will need to create a TppFileDevice descendent similar to the
TppArchiveDevice, that instead of writing an archive to a file, writes each
page to memory. You can take a look at the source for the TppArchiveDevice
in the ppFilDev.pas file.
As an alternative, you could print each archive to file then use the Archive
Merge Utility, created by one of our customers to merge them easily. If you
would like a copy of this utility, please send a quick email to
support@digital-metaphors.com requesting it.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Actually I am aware of the archive merge utility and have already received
it from you. My fall-back plan is to save the archive files, merge them as
you suggest below. But I just want to give a try first to do everything
using streams so that I don't have to clean up.
Vikram