asked on
function LoadFromFile(const AFileName: string; ARichEdit: TRichEdit);
begin
ARichEdit.Lines.Clear;
ARichEdit.Lines.LoadFromFile(AFileName);
end;
ASKER
function LoadFromFile(const AFileName: string): string;
var
List: TStringList;
begin
List := TStringList.Create;
try
LoadFromFile('C:\Windows\test.txt', List);
Result := List.Text;
finally
FreeAndNil(List);
end;
end;
ASKER
ASKER
procedure TForm1.Button1Click(Sender: TObject);
var
MyFile:TextFile;
Txt: string;
begin
AssignFile(MyFile,'C:\Windows\test.txt');
Reset(MyFile);
while not EOF(MyFile) do
begin
Readln(MyFile,Txt);
Memo1.Lines.Add(Txt)
end;
CloseFile(MyFile);
end;
ASKER
ASKER
ASKER
Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.
TRUSTED BY
Where do you want to load the file contents?
Lets say you want them in a TMemo
Open in new window