我如何删除xxxx.app目录中的文件
|
我有以下代码:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path1 = [[NSBundle mainBundle] pathForResource:@\"myFile\" ofType:@\"txt\"];
if([fileManager fileExistsAtPath:path1]) {
NSLog(@\"-- sample file found --\");
AccessQuestionsDB *accessQuestionDataFunction = [AccessQuestionsDB new];
idCounter = [accessQuestionDataFunction populateTheDatabase: path1 theID:0 firstTime: YES];
[accessQuestionDataFunction release];
[fileManager removeItemAtPath:path1 error:NULL];
if ([fileManager fileExistsAtPath:path1]) {
NSLog (@\"Remove %@ successful\", path1);
} else {
NSLog (@\"Remove %@ failed\", path1);
}
}
else {
NSLog(@\"-- NO SAMPLE FILE! --\");
}
输出:
2011-06-13 21:41:04.471 xxxx[1726:707] Remove /var/mobile/Applications/B1CC3E09-2A1D-4CD7-976D-E190A238EC79/xxxx.app/myFile.txt successful
当我运行程序时,表明文件已删除,请参见上文,但不是。当我使用\“ iPhone Explorer \”进行检查时,文件仍然位于\“ xxxx.app \”目录中,我猜这是应用程序的根目录。
如果有人可以向我展示如何真正删除此文件,我将不胜感激,因为我需要将其删除。
没有找到相关结果
已邀请:
2 个回复
豹芜澈
糖固傻染
之所以输出“删除成功”,是因为您在ѭ3when(即未删除它)时输出了该信息。