能用代码解决的问题都不是问题
/**
* 解决无限创建的子文件夹删除不了的问题
* @author wuhaifei
*/
public class ForeverDelete {
private void deleteDir(File file) {
if (file.listFiles().length == 0)
file.getAbsoluteFile().delete();
}
public void deleteFile(File file) {
File[] temp = file.listFiles();
for (int i = 0; i < temp.length; i++) {
System.out.println(temp[i].getName());
if (temp[i].isDirectory()) {
if (temp[i].listFiles().length != 0)
this.deleteFile(temp[i]);
this.deleteDir(temp[i]);
} else {
temp[i].delete();
}
}
}
public static void main(String[] args) {
ForeverDelete m = new ForeverDelete();
m.deleteFile(new File("F:\gitBlog\haifeiwu"));
}
}