Read write binary file delphi
It must than write the length to the file, and then the string data to the file. I may be able to help if I can get a feel for exactly what you are doing It's best I think to store data in a file by name, not by it's length and location within the file. I can make you a demo that lets you store any string of any length into pretty much any file and retrieve,replace,delete,al ter it by refering to it by name..
FILE routines should be marked deprecated and abandoned in the next delphi release.. Thanks zebeda you answer worked. It is strange as my source code was pretty much identical to yours and just wouldn't work. I can't tell the difference between the two At least it works nwo though: Hi Gary, Post your original code, that should show what the problem was. Question has a verified solution. Sign up with Google. Sign up with LinkedIn. Sign up with Facebook. I would like to receive news, updates and offers from Experts Exchange.
What version of Delphi are you using? It would be much better to detect a corrupt file and report an error. If the user messes the file up then that's their problem. Store it under their user profile and there's no reason for them to mess around with it.
Craig; A free tip; Binary files are trouble. If you don't need to make custom binary file formats, then don't. Text files are much more "rugged and reliable", and easier to troubleshoot when malformed. TEncoding ; var crc: Size - Sizeof crc ; Stream. Create 'CRC error' ; temp. Create; try inherited SaveToStream temp, Encoding ; temp. Write crc, Sizeof crc ; Stream. I have since resolved my original problem without the use of any CRC checking.
I will accept your answer however as it seems very useful, I will have to look at it more closer to research it.