fun deleteFile(path: String?): Boolean { if (Handler_String.isBlank(path)) { return true } val file = File(path) if (!file.exists()) { return true } if (file.isFile()) { return file.delete() } if (!file.isDirectory()) { return false } for (f in file.listFiles()) { if (f.isFile()) { f.delete() } else if (f.isDirectory()) { deleteFile(f.getAbsolutePath()) } } return file.delete() }
delete file or directory < ul > < li > if path is null or empty , return true < /li > < li > if path not exist , return true < /li > < li > if path exist , delete recursion . return true < /li > < ul >