【问题标题】:remove inbox folder after open in files from other app to my app从其他应用程序打开文件到我的应用程序后删除收件箱文件夹
【发布时间】: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


【解决方案1】:

此目录似乎无法删除,因为它是从系统创建的,您无权这样做。 虽然没有很清楚地说明,但docs 至少给了你一个提示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-17
    • 1970-01-01
    • 2014-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多