public boolean isParent(File folder,File file){
  if (folder == null || file == null) {
    return false;
  }
 else   if (folder instanceof ShellFolder) {
    File parent=file.getParentFile();
    if (parent != null && parent.equals(folder)) {
      return true;
    }
    File[] children=getFiles(folder,false);
    for (    File child : children) {
      if (file.equals(child)) {
        return true;
      }
    }
    return false;
  }
 else {
    return folder.equals(file.getParentFile());
  }
}

public boolean isParent ( File folder , File file ) { if ( folder == null || file == null ) { return false ; } else if ( folder instanceof ShellFolder ) { File parent = file . getParentFile ( ) ; if ( parent != null && parent . equals ( folder ) ) { return true ; } File [ ] children = getFiles ( folder , false ) ; for ( File child : children ) { if ( file . equals ( child ) ) { return true ; } } return false ; } else { return folder . equals ( file . getParentFile ( ) ) ; } }
on windows , a file can appear in multiple folders , other than its parent directory in the filesystem . folder could for example be the " desktop " folder which is not the same as file . getparentfile ( ) .
