S shevachenko Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-29 #1 我删除文件从指定位置开始定长的字节,然后将文件后部前移,即填补删除后留下的空缺,然后改变文件的长度,长度变为(文件原长 - 删除长度),有什么函数可以实现改变文件长度[]
T twos Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-29 #3 使用TFileStream呀,用TFileStream把文件装入,然后操作 具体看帮助
S shevachenko Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-29 #4 vc中有setfilelength(),vb中有chsize(),delphi中就没有这样的函数吗?用filestream能具体提供一个例子吗?非常感谢,在线等待![]
M MikeZ Unregistered / Unconfirmed GUEST, unregistred user! 2002-09-07 #5 var fs1, fs2: TFileStream; p: PChar; l: integer; begin fs1 := TFileStream.Create(FileName, fmOpenRead); l := fs1.size - you_lines; getmemo(p, l); fs1.seek(you_lines, soFromBeginning); fs1.read(p, l); freeandnil(fs1); fs2 := TFileStream.create(filename, fmOpenWrite); fs2.write(p, l); freeandnil(fs2); freemem(p); end;
var fs1, fs2: TFileStream; p: PChar; l: integer; begin fs1 := TFileStream.Create(FileName, fmOpenRead); l := fs1.size - you_lines; getmemo(p, l); fs1.seek(you_lines, soFromBeginning); fs1.read(p, l); freeandnil(fs1); fs2 := TFileStream.create(filename, fmOpenWrite); fs2.write(p, l); freeandnil(fs2); freemem(p); end;