title: Getting windows ‘ShFileOperation’ API to recursively delete files in Delphi
body: <p>I am using the following code to delete a large number of files </p>
  
  <pre><code>function FastDelete(const fromDir: string): Boolean;
  var
    fos: TSHFileOpStruct;
  begin
    ZeroMemory(@fos, SizeOf(fos));
    with fos do
    begin
      wFunc := FO_DELETE;
      fFlags := FOF_FILESONLY or
                FOF_NOCONFIRMATION or
                FOF_NO_CONNECTED_ELEMENTS or
                FOF_NOERRORUI or
                FOF_NO_UI;
      pFrom := PChar(fromDir+'\*.*' + #0);
    end;
    Result := (0 = ShFileOperation(fos));
  end;
  </code></pre>
  
  <p>How do I get it to recursively delete all the files in the path?</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/bb759795(VS.85).aspx" rel="nofollow noreferrer">MSDN documentation</a>  </p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>The problem is the <strong>FOF_FILESONLY</strong> flag
  After removing it files are recursively deleted</p>