删除iPhone沙箱中的所有文件(文档文件夹)? [英] Deleting all the files in the iPhone sandbox (documents folder)?
本文介绍了删除iPhone沙箱中的所有文件(文档文件夹)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种简单的方法可以删除我保存在应用程序文档文件夹中的所有文件(图像)?
Is there an easy way to delete all the files(images) I saved in the documents folder of the app?
推荐答案
NSFileManager *fileMgr = [[[NSFileManager alloc] init] autorelease];
NSError *error = nil;
NSArray *directoryContents = [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error];
if (error == nil) {
for (NSString *path in directoryContents) {
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:path];
BOOL removeSuccess = [fileMgr removeItemAtPath:fullPath error:&error];
if (!removeSuccess) {
// Error handling
...
}
}
} else {
// Error handling
...
}
这篇关于删除iPhone沙箱中的所有文件(文档文件夹)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文