<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=ISO-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18813">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff text=#000000>
<DIV><FONT size=2 face=Arial>Is there a simple way to alter the size of an
existing file - particularly to decrease the size?</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>If increasing I can append some blank data on the
end no problem using TFilestream, no problem.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>The thing I am not sure about is if
I can DECREASE the size of a file by a known number of
bytes</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>(</FONT><FONT size=2 face=Arial>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);</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>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.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>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.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>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.)</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>John</DIV></BODY></HTML>