Excluir arquivos usando curingas (*.*) no Delphi
{ - Coloque um Button no Form;
- Altere o evento OnClick do Button conforme abaixo: }
procedure TForm1.Button2Click(Sender: TObject);
var
SR: TSearchRec;
I: integer;
begin
I := FindFirst('c:\Teste\*.*', faAnyFile, SR);
while I = 0 do begin
if (SR.Attr and faDirectory) <> faDirectory then
if not DeleteFile('c:\Teste\' + SR.Name) then
ShowMessage('Não consegui excluir c:\Teste\' + SR.Name);
I := FindNext(SR);
end;
end;
No exemplo acima todos os arquivos do diretório c:\Teste serão excluídos.
CUIDADO! Arquivos excluídos desta forma não vão para a lixeira.