delphi read file

Solutions on MaxInterview for delphi read file by the best coders in the world

showing results for - "delphi read file"
Caterina
30 Mar 2019
1	
2 var
3   myFile : TextFile;
4   text   : string;
5 
6 begin
7   // Try to open the Test.txt file for writing to
8   AssignFile(myFile, 'Test.txt');
9   ReWrite(myFile);
10 
11   // Write a couple of well known words to this file
12   WriteLn(myFile, 'Hello');
13   WriteLn(myFile, 'World');
14 
15   // Close the file
16   CloseFile(myFile);
17 
18   // Reopen the file for reading
19   Reset(myFile);
20 
21   // Display the file contents
22   while not Eof(myFile) do
23   begin
24     ReadLn(myFile, text);
25     ShowMessage(text);
26   end;
27 
28   // Close the file for the last time
29   CloseFile(myFile);
30 end;