FileSearch (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example uses an edit control and a button on a form. When the button is clicked, the current directory is searched for the file name specified in the edit control. A message box indicates whether the file is found.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  FileToFind: string;
begin
  FileToFind := SysUtils.FileSearch(Edit1.Text, GetCurrentDir);
  if FileToFind = '' then
    ShowMessage('Couldn''t find ' + Edit1.Text + '.')
  else
    ShowMessage('Found ' + FileToFind + '.');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label2.Caption := GetCurrentDir;
end;

Uses

Personal tools
Assistance