swift - 如果我希望允许用户管理文件夹和文件,我该如何处理文档目录中的收件箱文件夹?

标签 swift import file-manager

我有一个应用程序,用户可以在其中使用文件管理器来创建、修改和删除目录以及文件。我注意到,从外部应用程序导入文件时,会自动生成系统文件夹 Inbox,防止用户删除该文件夹和/或命名名为 Inbox 的文件夹。我是否应该在文档路径目录中创建一个子目录,并让文件管理器将该文件夹视为文档根路径?其他应用程序如何实现这一目标?

最佳答案

如果您允许用户在沙箱的文档目录中创建自己的文档和目录,那么最好按照您的建议进行操作,并在文档中创建一个单独的目录,指定用于用户可编辑的数据。

例如,也许在文档中添加一个“用户”目录,然后将其用作用户文件和目录的根目录。

Apple 的文档对/Documents/Inbox 进行了以下说明:

Use this directory to access files that your app was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your app in this directory. Document interaction controllers may also place files in it. Your app can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes. The contents of this directory are backed up by iTunes.

来自File System Programming Guide .

关于swift - 如果我希望允许用户管理文件夹和文件,我该如何处理文档目录中的收件箱文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37035430/

相关文章:

ios - 在 Swift 中加速 TableView 加载 JSON

javascript - 我在 Vue.js 项目中作为模块导入导入的图像时遇到问题

customization - 在 FAR 管理器中按日期排序文件

iPhone sdk - 将文件移动到目录

javascript - 在 TinyMCE 上设置响应式文件管理器

ios - AVCapturePhotoOutput 崩溃

ios - 使用私钥和 TouchID 或 FaceID swift 对消息进行签名

ios - Swift - 弹出 View ,日期选择器?

import - 如何在dm脚本中导入其他源代码文件

android - 无法在 React Native 中使用新导入的组件?