unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  F: TextFile;
  S: string;
begin
  if Opendialog1.Execute then            // okno dialogowe
  begin
    AssignFile(F, Opendialog1.FileName); //jeśli plik wybrany
    Reset(F);
    Readln(F, S);                        // czytaj pierwszą linię
    Edit1.Text := S;                     // przypisz linię do okienka edit
    CloseFile(F);
  end;
end;

end.
