Is there a simple way to alter the size of an existing file - particularly to
decrease the size?
If increasing I can append some blank data on the end no problem using
TFilestream, no problem.
The thing I am not sure about is if I can DECREASE the size of a file by a
known number of bytes
(Background - this is a single data file in use by more than one place in the
file from time to time, so I prefer to access it using TFileStream, as that can
do a better job of simultaneous access than assignfile/text file/file (which
does tend to lock a file for exclusive access at times). I use fs :=
Tfilestream.create(FileName, fmOpenRead or fmShareDenyNone);
>From time to time the file needs to have records added or deleted. Up to now
>I did this by recreating the file with a temporary name then renaming it over
>the original.
Despite taking all the care to make sure no process is reading the file when I
do this, Windows does frequently complain about it being in use by another
process - I think it is an issue to do with Windows cached reads and writes
still not completed, or Windows being a little out of date with its record of
what is using the file.
I think I will have switch to rewriting the data in place by rewriting the part
of the file that has changed, which I know how to do, except I don't know how
to shorten the file if needed.)
John
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
unsubscribe