`

ios拷贝文件,error code 516

 
阅读更多

今天写了一段拷贝文件的代码:

NSBundle *bundle=[NSBundle mainBundle];
    NSString *srcPath=[bundle pathForResource:@"images" ofType:@"zip"];// Bundle内的images.zip文件
    
    NSString *enterprisePath = [imagesPath stringByAppendingPathComponent:@"/test"];// documents/images/test
//  NSString *destPath = [enterprisePath stringByAppendingString:@"/images.zip"];
    
    NSError* error;
    NSFileManager *fileManager=[NSFileManager defaultManager];
    [fileManager copyItemAtPath:srcPath toPath:enterprisePath error:&error];

这段代码拷贝没有成功,报错是NSCocoaErrorDomain - code:516

搜索了一番发现,是destPath写得不对,只写到目录的path。如果要拷贝文件,需要写到文件名才行。把上面那段代码的注释放开就可以了

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics