title: Strange error when deleting directory from Java: 0 bytes, access denied
body: <p>I have written method that recursively deletes directory with its contents.
  Code is executed on Windows - Eclipse - JVM7</p>
  
  <p>Here's the code:</p>
  
  <pre><code>    /**
   * Empty and delete a folder with recursion.
   * 
   * @param folder
   *            folder to empty
   */
  public static boolean rmdir(final String folderPath, boolean deleteParent) {
      File folder = new File(folderPath);
  
      // check if folder file is a real folder
      if (folder.isDirectory()) {
          File[] list = folder.listFiles();
  
          if (list != null) {
              for (int i = 0; i &lt; list.length; i++) {
                  File tmpF = list[i];
                  if (tmpF.isDirectory())
                      rmdir(tmpF.toString(), true);
  
                  tmpF.delete();
              }
          }
  
          if (deleteParent &amp;&amp; !folder.delete()) {
              return false;
          } else
              return true;
      }
  
      return false;
  }
  </code></pre>
  
  <p>When the code is executed no error is thrown, saying that directory has been deleted successfully.
  When I open drive to confirm deletion, I can still see the folder which is now 0 bytes in size with "Access denied" error when trying to open it.</p>
  
  <p><img src="https://i.stack.imgur.com/e3fXU.png" alt="Directory properties"></p>
  
  <p><img src="https://i.stack.imgur.com/cK82Y.png" alt="Directory security"></p>
  
  <p>EDIT:</p>
  
  <p>I am administrator, have all permissions and can R/W to this folder from Windows explorer (before Java breaks it).
  My question is has anyone seen this before and what could be the cause of this??</p>
  
  <p>One more thing:
  It seems that the directory gets set to "DeleteOnExit" instead of "Delete" right away.
  Because when program ends in Lotus Notes or Eclipse directory disappears.</p>