4 Replies Latest reply on Aug 23, 2007 6:30 PM by 807605

    Trouble deleting files

    807605
      Hello

      I have a servlet running on a Win XP server which runs code:
        
      String path = ("c:\\monolith2\\build\\web\\plots"); 
      File dir = (new File(path));
      if (dir.isDirectory()) {
        String[] children = dir.list();
        for (int i = 0; i < children.length; i ++) {
            File fileToDelete = (new File(children));
      fileToDelete.delete();
      }
      }


      To delete all the files in folder 'dir '.

      However, the files do not get deleted regardless of what I try and I cannot see why.

      Messages placed in the code shows that the folder is being found and I can list the files but the delete does not work.

      Any ideas? I have tried executing batch files to do the deletes but to no avail.

      Thanks

      Martin O'Shea.