Deleting Directory which has subtrees

Hi Device Driver Developers,

I have developed FileSystem filter driver and now I’m facing a problem.

My driver does

  1. Open target dir
  2. Scan dir with ZwQueryDirectoryFile and get file/dir name
  3. Open the scanned file and set disposition information
  4. Close the file handle
  5. Do 2~4 till the dir has no more entry remains
  6. If the scaned file is directory, does 1~5 and and delete the target dir itself

And, if the target dir has subtrees, the STATUS_DELETE_PENDING is returned when
my driver tries to delete the target dir after deleting subtrees.
How can I solve this problem?

Thanks in advance,

Jaehong