Anyone know how to reduce the length of an existing file?
Posted on 2003-03-13
I need to be able to write data to a file, and will not know in advance whether the final filesize will be smaller or larger than when the file was first opened.
No problem increasing the file length: The Put statement can save data past the end of a file open for binary access.
But I can't figure out how to shorten the file length. It's OK if I need to close the first and then use some function (API?), similar to UNIX's truncate() function.
I don't want to copy part of the file, then delete the original, because other applications will be accessing the file at the same time. (These other apps are well enough behaved to cope with changing filesizes, but of course, won't allow the file they're accessing to be deleted)
Thanks in advance!