0

I am using Delphi 7, while calling LoadFromFile from my REMObject Type I am randomly encountering a Stream Read Error.

The following line is where I get the error:

FileData.LoadFromFile(QItem.PDFPath);

What can I do to find and fix the error?

kapil sharma
  • 31
  • 1
  • 3
  • Are you by any chance modifying the file whilst reading it? – David Heffernan May 09 '11 at 11:29
  • No, we are just trying load the file and its occuring on files that are bigger in size. pls refer to http://qc.embarcadero.com/wc/qcmain.aspx?d=65522 for the same – kapil sharma May 09 '11 at 11:33
  • @kapil That QC report is for a memory stream. What type is `FileData`? – David Heffernan May 09 '11 at 11:34
  • @kapil did you try the workaround suggested in the QC report? – David Heffernan May 09 '11 at 11:35
  • @david:FileData is of binary type we are using this way only:FileData := Binary.Create; – kapil sharma May 09 '11 at 11:40
  • 1
    @kapil Is the `Binary` class part of Delphi? I'm not familiar with it. If it's a class of your making then I don't see how we can be expected to find bugs in your code! If it is a `TStream` descendant then I would comment that it is very easy to get the coding for such classes wrong so that you see stream read error exceptions – David Heffernan May 09 '11 at 11:42
  • @David:Any general reason to occur this type of error with this function if you could suggest. – kapil sharma May 09 '11 at 11:47
  • binary is a data type in delphi7 as string etc – kapil sharma May 09 '11 at 11:59
  • The function works well at so many places. It just gives error at a specific site – kapil sharma May 09 '11 at 12:02
  • @kapil: no, it's not; `var B:Binary` doesn't compile on my Delphi 7. – Cosmin Prund May 09 '11 at 12:02
  • Cosmin, try var test : binary; – kapil sharma May 09 '11 at 12:03
  • 1
    Ah, its Rem Objects type not delphi.. sorry – kapil sharma May 09 '11 at 12:04
  • See the brief code we are using:function TXACTest.ProcessPDFQueueXacToXas: Boolean; var cmd : string; ErrMsg : string; FileData : binary;try FileData.LoadFromFile(QItem.PDFPath); – kapil sharma May 09 '11 at 12:07
  • Afraid I can't help since I know nothing of this class. I suggest you contact RemObjects for support. – David Heffernan May 09 '11 at 13:03
  • Kapil, please post a minimal compilable example that exhibits the problem. The code in your last comment isn't even valid. Edit the question to add your code. – Rob Kennedy May 09 '11 at 13:45
  • @rob My current situation is FileData.LoadFromFile(QItem.PDFPath); LoadFromFile is the function which is causing errors Stream read error at regular interval of time,QItem.PDFPath the file location from where i am picking up the file so can you please let me know any other alternative for this function. – kapil sharma May 10 '11 at 09:03
  • I suggest you find out what anti-virus is on this site, and try disabling it for a day or so. Most likely the PDF is being scanned on close, which you then expect to open immediately, but the AV has nipped in quicker. – mj2008 May 12 '11 at 10:22
  • Kapil - you should definitely ask in Remobjects newsgroups - or they have a new beta forum at connect.remobjecs.com. On the other hand, will that problematic file load reliably in a normal TFileStream. in other words are you sure its the Binary.LoadFromFile thats the problem or the source file? – Stuart May 12 '11 at 10:31

0 Answers0