Getting windows ‘ShFileOperation’ API to recursively delete files in Delphi

前端 未结 2 1730
北恋
北恋 2021-01-27 00:24

I am using the following code to delete a large number of files

function FastDelete(const fromDir: string): Boolean;
var
  fos: TSHFileOpStruct;
begin
  ZeroMem         


        
2条回答
  •  [愿得一人]
    2021-01-27 00:43

    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.

提交回复
热议问题