【发布时间】:2014-08-02 15:42:42
【问题描述】:
我已使用此代码打开通过 openin 菜单从其他应用程序导入的其他文件 但问题是,当我在导入文档后尝试在 box 文件夹中删除时,它给了我权限错误
-(void)openImportedFile:(NSURL *)url{
NSFileManager *filemanager=[NSFileManager defaultManager];
NSString *strfilepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *inboxPath=[strfilepath stringByAppendingPathComponent:@"NewDocument"];
[filemanager createDirectoryAtPath:inboxPath withIntermediateDirectories:TRUE attributes:nil error:nil];
NSString *strInboxFilepath=[url path];
NSString *strdesPath=[inboxPath stringByAppendingPathComponent:[strInboxFilepath lastPathComponent]];
[self performSelector:@selector(deleteInboxFolder) withObject:nil afterDelay:0.5];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:strdesPath]];
self.docController.delegate = self;
[self.docController presentPreviewAnimated:YES];
}
这是删除收件箱文件夹的代码
-(void)deleteInboxFolder
{
NSFileManager *fm=[NSFileManager defaultManager];
NSError *error;
NSString *strfilepath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/Inbox",strfilepath];
[fm removeItemAtPath:path error:&error];
if(error){
NSLog(@"%@",error);
}
}
我收到了这个错误
Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x16d5e7f0 {NSUnderlyingError=0x16d5e6d0 "The operation couldn’t be completed. Operation not permitted", NSFilePath=/var/mobile/Applications/D1252FCA-A496-45EE-80FC-4F6692AF4545/Documents/Inbox, NSUserStringVariant=(
Remove
)}
我完全不知道该怎么办 请建议我解决方案 提前致谢
【问题讨论】:
-
你找到删除收件箱文件夹的方法了吗?
标签: ios objective-c ios7 nsfilemanager