Re: Writing Binary Files with TFileStream



Unless you're originally reading from a file of someone else's making,
why not use what I call "long short strings" in the file.

These consist of an integer (4 bytes) specifying the length of the
string, followed by char-count (length) number of bytes.

Then delegate the actual reading to small functions which take a stream
parameter, and read and return an integer, and another which reads and
returns a string (reading the integer first and then the chars). And of
course the corresponding write procedures which take parameters of a
stream and what is to be written.

Such lower level delegating would help protect you from the error you
made. Very slightly slower -yes- but smoother coding.

Alan Lloyd

.