Check if a file exists

Posted in Files & folders

Use FileExists function. If file exists, then this function will return True.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if FileExists(Edit1.Text) then
    ShowMessage('File already exists!')
  else
    ShowMessage('This file is unique');
end;

For more