I am using the following code to delete a large number of files
function FastDelete(const fromDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMem
From the MSDN documentation:
FOF_NORECURSION
Only perform the operation in the local directory. Don't operate recursively into subdirectories, which is the default behavior.
Looks like that's your answer right there. It should recurse automatically unless you ask it not to.
EDIT: Looks like there's a problem with your flags. You need to OR them together, not add them together. Since FOF_NO_UI
already includes FOF_NOERRORUI
, adding it again can change the value, and you might be accidentally adding some things together that add up to FOF_NORECURSION
. It should look like this:
fFlags := FOF_FILESONLY or
FOF_NOCONFIRMATION or
FOF_NO_CONNECTED_ELEMENTS or
FOF_NOERRORUI or
FOF_NO_UI;