title: Delete a file instead of marking it for deletion
body: <p>I am writing a service for Windows (from XP to 8.1). I need to recursively delete a folder and I use <code>DeleteFile</code> and <code>RemoveDirectory</code> for that.
  I don't want to use <code>SHFileOperation</code> because it has the <code>MAX_PATH</code> limit.</p>
  
  <p>The problem is that sometimes, <code>RemoveDirectory</code> fails with <code>ERROR_DIR_NOT_EMPTY</code>, even if the directory is empty.
  I found out that this is because <code>DeleteFile</code> works asynchronously, it only "marks" a file for deletion. Therefore, adding a small delay (Sleep) before calling <code>RemoveDirectory</code> fixes the issue. But I am looking for a cleaner method.</p>
  
  <p>So, is there a way to ensure that the marked files are well and truly deleted?</p>
  
  <p>I already tried to call <code>FlushFileBuffers</code> directly on the directory, without success.</p>
  
  <p>Edit: Some are claiming that <code>NtDeleteFile</code> can delete a file even if there are handles open on it. I just checked that and it's wrong, at least on Windows 8.1: the file is removed only when all the handles are closed.</p>