我写了一个过程,用来读取文件中得那容到文本筐中,但是总停留在第一行,不能读取下面得行,是怎么回事?
过程如下:
procedure TfrmMain.ShowOneFileINfo(dfile: string);
var
txtfile:TextFile;
s:string[25];
begin
Assignfile(txtfile,dfile);
reset(txtfile);
try
while not eof(txtfile) do
begin
readln(txtfile,s);
RichEdit1.Lines.Add(s);
end;
finally
closefile(txtfile);
end;
end;
过程如下:
procedure TfrmMain.ShowOneFileINfo(dfile: string);
var
txtfile:TextFile;
s:string[25];
begin
Assignfile(txtfile,dfile);
reset(txtfile);
try
while not eof(txtfile) do
begin
readln(txtfile,s);
RichEdit1.Lines.Add(s);
end;
finally
closefile(txtfile);
end;
end;
var
Textfile1 : TStringList;
Count : integer;
begin
try
Textfile1:=TStringList.Create;
Textfile1.LoadFromFile('d:/123.txt');
for Count:=0 to Textfile1.Count-1 do
RichEdit1.Lines.Add(Textfile1[Count]);
finally
freeandnil(Textfile1);
end;
end;