⤷ Remove all files from directory

Use the FindFirst and FindNext functions for searching files in directory. And DeleteFile function for removing files.

procedure TForm1.Button1Click(Sender: TObject);
var
  APath: string;
  MySearch: TSearchRec;
begin
  APath:=Edit1.Text;
  FindFirst(APath+'\*.*', faAnyFile+faReadOnly, MySearch);
  Memo1.Lines.Add(MySearch.Name);
  DeleteFile(APath+'\'+MySearch.Name);
  while FindNext(MySearch)=0 do
  begin
    Memo1.Lines.Add(MySearch.Name);
    DeleteFile(APath+'\'+MySearch.Name);
  end;
  FindClose(MySearch);
end;
More for developers