title: Marking files for deletion using MoveFileEx
body: <p>I'm having a bit of trouble getting MoveFileEx to work properly in Windows 7 x64.</p>
  
  <p>I'm running my application as administrator, marking files for deletion on next reboot but after rebooting find that none of the files are being deleted.</p>
  
  <p>I'm using the following to accomplish said feat: </p>
  
  <pre><code>    [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
      private static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
  
      private static IEnumerable&lt;string&gt; GetFiles(string path)
      {
          var queue = new Queue&lt;string&gt;();
          queue.Enqueue(path);
          while (queue.Count &gt; 0)
          {
              path = queue.Dequeue();
              try
              {
                  foreach (var subDir in Directory.GetDirectories(path))
                  {
                      queue.Enqueue(subDir);
                  }
              }
              catch (Exception ex)
              {
                  Console.Error.WriteLine(ex);
              }
              string[] files = null;
              try
              {
                  files = Directory.GetFiles(path);
              }
              catch (Exception ex)
              {
                  Console.Error.WriteLine(ex);
              }
              if (files != null)
              {
                  foreach (var t in files)
                  {
                      yield return t;
                  }
              }
          }
      }
   private void button1_Click(object sender, EventArgs e)
  {
    foreach (var files in GetFiles(sysRoot + @"\system32\spool\drivers\x64\"))
    {
      Log(files);
      MoveFileEx(files, null, MoveFileFlags.MovefileDelayUntilReboot);
    }
  }
  </code></pre>
  
  <p>I can verify the marking process is being done on multiple files, just can't figure out why it's not then performing the delete functionality after the machine has been rebooted. </p>
  
  <p>Any assistance in this area will be greatly appreciated. </p>
  
  <p>Thank you.</p>