public void deleteFile(File file) {
if (file.exists()) {
if (file.isFile()) {
file.setExecutable(true, false);
file.setReadable(true, false);
file.setWritable(true, false);
file.delete();
} else if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
this.deleteFile(files[i]);
}
}
file.setExecutable(true, false);
file.setReadable(true, false);
file.setWritable(true, false);
file.delete();
Toast.makeText(MainActivity.this, "文件已删除", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this, "文件不存在", Toast.LENGTH_LONG).show();
}
}
删除文件夹
最新推荐文章于 2022-10-23 18:52:39 发布