read text file into memo field

mares40
mares40 used Ask the Experts™
on
i have a text file (abc.txt) how can i read  this file into a memo field?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Memo1.Lines.LoadFromFile('abc.txt');
Mohammed NasmanSoftware Developer

Commented:
Hello

  if you Add the fields in the Field Editor you can do that simply as:

  Table1MemoField.LoadFromFile('abc.txt');

or try this way
  (Table1.FieldByName('MemoField') as TBlobField).LoadFromFile('c:\abc.txt');

I typed that in hurry, so if you have problems tell me,

Best regards
Mohammed Nasman

Author

Commented:
your code is working. but i have three separete txt say it abc.txt, bce.txt and dfg.txt. and i want to read the three files as separate paragraps. if i use use code the second txt is replacing  the first one. My aim is to add the second txt as a new paragraph into dbmemofield.
best regards
Commented:
I typed this quickly and haven't tried it in Delphi, but you get the idea :)

(* == CODE == *)
function AddTextfileToMemo(AMemo: TMemo; const AFilename: String): Boolean;
var
  StrList : TStringList;
begin
  result := False;
  if FileExists(AFilename) = False then Exit;
  with StrList.Create do
  try
    StrList.LoadFromFile(AFilename);
    AMemo.Lines.Text := AMemo.Lines.Text + StrList.Text;
    result := True;
  finally
    Free;
  end;
end;

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial