Delphi-Quellcode:
procedure RemoveFolder(const AFolderNameWithWildcard: string);
var
SearchRecord: TSearchRec;
BaseFilePath: string;
FoundName: string;
const
FILE_ATTRIBUTES = faDirectory;
begin
if FindFirst(AFolderNameWithWildcard, FILE_ATTRIBUTES, SearchRecord) = 0 then
begin
BaseFilePath := ExtractFilePath(AFolderNameWithWildcard);
repeat
FoundName := BaseFilePath + SearchRecord.Name;
if TDirectory.Exists(FoundName) then
TDirectory.Delete(FoundName);
until FindNext(SearchRecord) <> 0;
FindClose(SearchRecord);
end;
end;
So aufzurufen:
RemoveFolder('C:\Users\user.'+CompName+'\Desktop\*Ordner');
Wildcard ist zumeist ein Sternchen!