Delphi Code:
function DeleteFolders(Path: String): boolean;
var
StartTime: dword;
begin
Result := False;
try
TDirectory.Delete(Path, True);
// dit is de nieuwe loop i.p.v. een sleep(1000)
StartTime := GetTickCount;
while DirectoryExists(Path) and (GetTickCount < StartTime + 1000) do
Sleep(20);
if DirectoryExists(Path) then
begin
Logger(Format('Error cleaning up %s. Remove folder before continue', [Path]), etError);
Result := False;
end
else
begin
Logger(Format('Cleaning up %s succesful.', [Path]), etNormal);
Result := True;
end
except
on E: Exception do
begin
Logger(Format('Error cleaning up %s', [Path]), etError);
Logger(Format('System Error Message: %s', [SysErrorMessage(GetLastError)]), etError);
Logger(Format('Exception Message: %s', [E.Message]), etError);
end;
end;
end;