FileDelete 是简单的 iOS 类,可以从文档和库目录删除文件和子目录。
使用需要引入:
[FileDelete deleteFileFromDocumentsDirectory:@"helpme" inSubDirectory:nil]; [FileDelete deleteFileFromLibraryDirectory:@"helpme" inSubDirectory:@"help/theworld]; [FileDelete deleteSubDirectoryFromDocumentsDirectory:@"helpless"]; [FileDelete deleteSubDirectoryFromLibraryDirectory:@"Libraryofhelplessness/mine"];
Swift 版本方法:
// Delete files FileDelete.deleteFileFromDocumentsDirectory("YourFile.extension",subdirectory:"YourDirectory") FileDelete.deleteFileFromLibraryDirectory("YourFile.extension",subdirectory:"YourDirectory") FileDelete.deleteFileFromApplicationSupportDirectory("YourFile.extension",subdirectory:"YourDirectory") FileDelete.deleteFileFromTemporaryDirectory("YourFile.extension",subdirectory:"YourDirectory") FileDelete.deleteFileFromCachesDirectory("YourFile.extension",subdirectory:"YourDirectory") // Delete folders FileDelete.deleteSubDirectoryFromDocumentsDirectory("YourDirectory") FileDelete.deleteSubDirectoryFromLibraryDirectory("YourDirectory") FileDelete.deleteSubDirectoryFromApplicationSupportDirectory("YourDirectory") FileDelete.deleteSubDirectoryFromTemporaryDirectory("YourDirectory") FileDelete.deleteSubDirectoryFromCachesDirectory("YourDirectory")