1个回答
展开全部
//将数据先读入内存然后重新写入文件就可以了;
//文件比较大建议用拷贝文件方式;
//
procedure TForm1.Button1Click(Sender: TObject);
var
f: TextFile;
sfile:TStrings;
filename,s:string;
i:Integer;
begin
filename:='需要处理问题';
if FileExists(filename) then
begin
sfile:=TStringList.Create;
AssignFile(f,filename);
Reset(f);
while not Eoln(f) do
begin
Readln(f,s);
sfile.Add(s);
end;
Rewrite(f);
for i := 1 to sfile.Count-1 do
begin
writeln(f,sfile.Strings[i]);
end;
CloseFile(f);
sfile.Free;
end;
end;
//文件比较大建议用拷贝文件方式;
//
procedure TForm1.Button1Click(Sender: TObject);
var
f: TextFile;
sfile:TStrings;
filename,s:string;
i:Integer;
begin
filename:='需要处理问题';
if FileExists(filename) then
begin
sfile:=TStringList.Create;
AssignFile(f,filename);
Reset(f);
while not Eoln(f) do
begin
Readln(f,s);
sfile.Add(s);
end;
Rewrite(f);
for i := 1 to sfile.Count-1 do
begin
writeln(f,sfile.Strings[i]);
end;
CloseFile(f);
sfile.Free;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询