William,

obviously the record is *not* the same, otherwises it would work.
You should check the alignment of the fields in the record.
For records to be written to disk it is always a good idea to declare them as PACKED RECORD to avoid problems like yours.


Good luck,
Gunnar

----- Original Message ----- From: <wvido...@metsec.com>
To: <delphi@elists.org>
Sent: Friday, August 20, 2010 5:32 PM
Subject: Error reading Binary files using Delphi2006


Dear All,



I wrote an application using delphi5 which reads and writes  binary file
using TFilestream.  But then when I ported the application to Delphi
2006 the files written using old application returns junk data in the
new version.



Sample file open procedure:



procedure OpenProjectFile;

var FSave:TFileStream;

begin

    //open an existing project file

     FSave:=TFileStream.Create(Open1.FileName,fmOpenReadWrite);

     FSave.Read(MyData,Sizeof(MyData));

     FSave.Free;

end;



MyData is a record which is the same in both sources.

I am at a loss why this is happening. Can anyone throw some light on
this?





Thanks William


This email is intended for the addressee only.

Please see our email policy at http://www.metsec.com/asp/home/edisclaimer.asp
_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
Gunnar Blumert Softwareentwicklung
Waldstr. 117
25712 Burg (Dithmarschen)
Germany
Tel. +49-(0)4825-2892 (14.00-16.00h)
Fax: +49-(0)4825-1217
Email gun...@blumert.de
www.blumert.de

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to