你先移动文件指针,然后使用 Truncate(f);
就可以达到你的目的。
procedure Truncate(var F);
Description
In Delphi code, Call Truncate to cause the current file position to become end-of-file (Eof(F) is true).
F is a file variable of any type except a text file. Truncate does not work on text files. F must be open.