TOpenDialogFileName (Delphi)
Description
Use a TOpenDialog to select a file. Place the first line of the file into a TEdit. Click the text edit to open the dialog box.
Code
procedure TForm1.Edit1Click(Sender: TObject);
var
F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box. }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in the dialog }
Reset(F);
Readln(F, S); { Read the first line of the file }
Edit1.Text := S; { Put string in a TEdit control. }
CloseFile(F);
end;
end;
Uses
- Vcl.Dialogs.TOpenDialog.FileName ( fr | de | ja )
- Vcl.Dialogs.TOpenDialog.Execute ( fr | de | ja )
- System.AssignFile ( fr | de | ja )
- System.Readln ( fr | de | ja )
- System.CloseFile ( fr | de | ja )