NSCococErrorDomain 513 - 从文档目录中删除文件夹 - ios设备

时间:2014-02-21 14:15:51

标签: ios iphone objective-c xcode ios5

我正在尝试从文档目录中删除该文件夹,但我得到的是NSCococErrorDomain 513.请帮帮我。

模拟器它工作正常,但在设备中,它显示此错误。

我已经分享了以下代码。

创建文件夹:

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"Message"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
        [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:YES attributes:nil error:nil]; 

删除文件夹

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSMutableString *pathMString = [[NSMutableString alloc]initWithString: [paths objectAtIndex:0]];
[pathMString appendFormat:@"/%@",@"Message"];
 NSError *err = nil;
NSString *dataPath = [NSString stringWithString:pathMString];
if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath])
{

    //DEBUGLOG(@"/n/n/n/n/n/Path/n/n/n/n/n//n/n/n/n/n//n/n/n/n/n/ : %@",dataPath);
    [[NSFileManager defaultManager] removeItemAtPath:dataPath error:&err];
    if (err)
    {
        //DEBUGLOG(@"Unable to delete existing file.\n" "Error: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
        return;
    }

}

感谢

0 个答案:

没有答案