title: Delete Directory with non empty subdirectory and files
body: <p>How to delete one directory having some files and some non empty sub directory.<br>
  I have tried <a href="https://stackoverflow.com/questions/11798783/delete-all-files-and-folders-recursively-using-delphi"><strong>SHFileOperation Function</strong></a>. It has some compatibility issue in <a href="http://msdn.microsoft.com/en-us/library/bb762164%28v=vs.85%29.aspx" rel="nofollow noreferrer"><strong>Windows 7</strong></a>.<br>
  Then I have tried <a href="http://msdn.microsoft.com/en-us/library/bb775771%28v=vs.85%29.aspx" rel="nofollow noreferrer"><strong>IFileOperation Interface</strong></a>. But it is not compatible in <strong>Windows XP</strong>.
  Then I have tried the following codes as suggested by <a href="https://stackoverflow.com/questions/11798783/delete-all-files-and-folders-recursively-using-delphi"><strong>David Heffernan</strong></a> :  </p>
  
  <pre><code>procedure TMainForm.BitBtn01Click(Sender: TObject);
  var
    FileAndDirectoryExist: TSearchRec;
    ResourceSavingPath : string;
  begin
    ResourceSavingPath := (GetWinDir) + 'Web\Wallpaper\';
    if FindFirst(ResourceSavingPath + '\*', faAnyFile, FileAndDirectoryExist) = 0 then
    try
      repeat
        if (FileAndDirectoryExist.Name &lt;&gt; '.') and (FileAndDirectoryExist.Name &lt;&gt; '..') then
          if (FileAndDirectoryExist.Attr and faDirectory) &lt;&gt; 0 then
            //it's a directory, empty it
            ClearFolder(ResourceSavingPath +'\' + FileAndDirectoryExist.Name, mask, recursive)
          else
            //it's a file, delete it
            DeleteFile(ResourceSavingPath + '\' + FileAndDirectoryExist.Name);
      until FindNext(FileAndDirectoryExist) &lt;&gt; 0;
      //now that this directory is empty, we can delete it
      RemoveDir(ResourceSavingPath);
    finally
      FindClose(FileAndDirectoryExist);
    end;
  end;
  </code></pre>
  
  <p>But it does not get compiled mentioning error as Undeclared Identifier at <strong>ClearFolder</strong>, <strong>mask</strong> and <strong>recursive</strong>. My requirement is to that "If any sub folder exist under WALLPAPER folder it will be deleted". The same sub folder may contain any number of non empty sub folder or files.</p>