If I were you, I would just tell the operating system to delete the folder with all the contents. Do this by writing ( uses ShellAPI )
var ShOp: TSHFileOpStruct; begin ShOp.Wnd := Self.Handle; ShOp.wFunc := FO_DELETE; ShOp.pFrom := PChar('C:\Users\Andreas Rejbrand\Desktop\Test\'
[If you do
ShOp.fFlags := 0;
instead, you will get a good confirmation dialog. If you do
ShOp.fFlags := FOF_NOCONFIRMATION;
you will not get a confirmation dialog, but you will get a progress bar if the operation is long. Finally, if you add the FOF_ALLOWUNDO flag, you move the directory to the waste bin, rather than deleting it.
ShOp.fFlags := FOF_ALLOWUNDO;
Of course, you can combine the flags as you wish:
ShOp.fFlags := FOF_NOCONFIRMATION or FOF_ALLOWUNDO;
no confirmation will be displayed (but a progress dialog, because you do not specify FOF_NO_UI ), and the directory will be moved to the garbage bin and not permanently deleted.]
Andreas Rejbrand
source share