假如我有一个test.txt文档
内容如下:
——————————————
Loving you
is easy 'Cos you're beautiful
loving you
is all I want to do
Loving you
is more that
Just a dream come true
And everthing I do
is out of loving you
La La...Doo un doo un doo doo, Ah...
——————————————请问我怎样通过delphi来把文本里面的内容按行,一行一行地写到memo里面去
内容如下:
——————————————
Loving you
is easy 'Cos you're beautiful
loving you
is all I want to do
Loving you
is more that
Just a dream come true
And everthing I do
is out of loving you
La La...Doo un doo un doo doo, Ah...
——————————————请问我怎样通过delphi来把文本里面的内容按行,一行一行地写到memo里面去
procedure TForm1.Button1Click(Sender: TObject);
var
F: TextFile;
sFName, sText: String;
begin
sFName := 'e:\test.txt';
if Not FileExists(sFName) then exit;
try
AssignFile(F,sFName);
Reset(F);
Memo1.Clear;
while Not Eof(F) Do
begin
ReadLn(F,sText);
Memo1.Lines.Add(sText);
end;
finally
CloseFile(F);
end;
end;