I am using the following code to delete a large number of files
function FastDelete(const fromDir: string): Boolean;
var
fos: TSHFileOpStruct;
begin
ZeroMem
Do you have to keep the directory also? If not you could just pass
pFrom := PChar(fromDir+#0);
Another option is to build a list of #0-delimited file-paths, and pass that with an extra #0, from msdn:
Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.