I have the below function to delete a directory tree. but does not seem to work in all cases. if the inner file name is too long does not seem to be removing. any solution?
public static boolean deleteDirectory(File path) {
if( path.exists() ) {
File[] files = path.listFiles();
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory())
{
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
return( path.delete() );
}
Start Free Trial