Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

ArchiveReader locking up file?

edited October 2003 in General
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.

Comments

  • edited October 2003
    Hoi Stijn,

    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





  • edited October 2003
    Hoi Rob,

    Thanks for the offer. Well I just quickly create & destroy it now :).

  • edited March 2004
    "Rob Segerink" wrote in message news:3f9cd8be@dm500....

    Can I have the archivestreamreader component?
    Appreciate your help.

    Please email it to vikram@captools.com

    Vikram
  • edited March 2004
    "Rob Segerink" wrote in message news:3f9cd8be@dm500....

    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
  • edited March 2004
    ---------------------------------------------------
    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;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    "Nico Cizik (Digital Metaphors)" wrote in
  • edited March 2004
    Vikram,

    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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    What does it take to implement it? Can you give me some pointers and
    indicate how hard it is?
    I need to generate separate reports in memory and combine them later on.

    Thanks
    Vikram

  • edited March 2004
    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.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2004
    Thank you very much for the heads up.
    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

This discussion has been closed.