- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在云端有一个 15.2 kb 的文件。我无法将其复制回应用程序沙箱。下面列出了我的代码。感谢任何帮助
NSURL *ubiq = [[NSFileManager defaultManager]
URLForUbiquityContainerIdentifier:nil];
if (ubiq)
{
NSError *error = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *cloudContainerURL = [fileManager URLForUbiquityContainerIdentifier:nil]:
NSURL*dirURL=[cloudContainerURL URLByAppendingPathComponent:@"Documents" isDirectory:YES];
[fileManager createDirectoryAtURL:dirURL withIntermediateDirectories:NO attributes:nil error:&error];
NSURL *icloudURL = [dirURL URLByAppendingPathComponent:@"Passwords File.txt"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
// Destination path
NSString *fileInDocumentsPath = [documentsPath stringByAppendingPathComponent:@"Passwords File.txt"];
NSURL* sandboxDocumentURL = [NSURL fileURLWithPath:fileInDocumentsPath];
[[ NSFileManager defaultManager ] copyItemAtURL:icloudURL toURL:sandboxDocumentURL error:&error ];
最佳答案
您不能直接将文件从 iCloud 复制到本地目录,因为该文件可能尚不存在于本地设备上。您的应用程序的 iCloud 文件仅按需下载,并且您没有执行任何操作来创建该需求。因此,没有可复制的源文件。即使您知道该文件位于云端,您也无法访问它,除非它存在于本地。
如果您正在检查传递给 copyItemAtURL:toURL:error:
的 error
参数,您可能已经知道这一点。
要下载文件,请使用-[NSFileManager startDownloadingUbiquitousItemAtURL:error:]
。这就是整个过程的开始。您可以使用以下方法之一了解下载何时完成:
NSMetadataQuery
,下载完成后将发布更新,或者NSFileManager
,它不会通知您,但有一个可供您检查的 NSURLUbiquitousItemIsDownloadedKey
标志。关于ios - 如何使用文件管理器将 iCloud 中的文件复制到应用程序沙箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17775970/
如何在 C# 中检测两个文件是否完全相同(大小、内容等)? 最佳答案 这是一个简单的解决方案,它只读取两个文件并比较数据。它应该不会比散列方法慢,因为这两种方法都必须读取整个文件。 编辑 正如其他人所
我正在为我的工作编写一个简单的文档管理系统。我只是一个爱好者,但已经编程了一段时间了。我的问题是这样的。当我通过我的应用程序删除了一些文档时,我需要删除相关的数据库记录。如果抛出异常,最好的解决方法是
我已经使用 Xcode 一段时间了。一直困扰我的一件事是它处理文件的方式。我喜欢将我的文件全部放在嵌套文件夹中,而不是一个大的物理文件夹中,但是默认情况下,当您在 Xcode 中创建一个组时,它不会创
我正在使用 DNN 5.6.2,并且正在尝试构建一个自定义模块,用户可以在其中上传我对其运行验证的文件。如果文件有效,则将其保存。模块创建了一个根级目录“DataValidation”,并且模块的每个
我一直在尝试在某些目录中创建文件,但一直无法弄清楚。 重点是在包dir中创建文本文件:com.resources.files但我的想法不起作用。 public boolean archiveFile(
我们使用 Realm 一段时间了,我们的一些用户遇到了一些与 Realm 相关的数据丢失问题。我们认为我们已经将范围缩小到文件变得太大时的压缩方法。我们想就这是否是重新创建 Realm 文件的正确方法
我正在学习 Linux,我需要创建一个允许输入重定向 (stdin) 和输出重定向 (stdout) 的函数。我发现了一个示例,其中实际创建了一个文件文本,该文件文本的名称是我选择的名称。但是我不明白
我正在做我的学校作业,我遇到了我的第一个主要障碍......我无法写入文件,甚至无法使用 scanf 和 fgets 检索输入。 问题一: FILE *f1; char date_trans[100]
我的猜测是错误的,与答案无关。这个问题不再有效。请参阅my answer 。很抱歉这个糟糕的问题。 Tl;dr 版本 为什么 Java 进程无法找到某个文件,直到另一个进程(创建该文件的进程)完成执行
如何在 java 中过滤单引号 '? 我有一个搜索框,如果有人输入单引号,我会收到一个数据库错误。 我不想在 JavaScript 或数据库级别对其进行归档;我只想用 Java 来做。我该怎么做? 我
我是 ios 开发的新手,我遇到了与内存管理和处理大型数据集的方法有关的问题。 现在,我正在加载 csv 文件并将相关数据作为对象存储在应用程序初始化时的内存中。一些 csv 文件大于 1MB,我的应
我正在构建一个包含我自己的 *.c 和 *.h 文件的小型库,但我不确定应该如何管理它们,尤其是在将它们包含到项目中时。我在 Ubuntu 上使用 Codeblocks 以防万一。对于每个 .c/.h
我正在为我的数据结构编程课做大学作业。我们正在为这项任务分组工作,所以我目前正在处理我的一个队友项目。我添加了本地 READ/WRITE 代码,这样我就可以将数组列表保存到本地 .dat 文件中。但是
我在上传文件时使用数据库来命名文件,我的应用程序使用数据库来识别文件(用于视频流),因此它们需要相同。但是,如果上传失败,或者有人取消上传,我就会留下一个浪费的 ID。 加类 我有更多浪费的 ID 号
我的想法是创建一个包含服务的 .jar 文件 由 Spring 管理,应该由 getBean() 获取 我想把它放到 Web-app 的 WEB-INF/lib 然后在网络应用程序 Servlet 中
我在 Rails 开发中使用 SASS 文件。我想知道我是否应该gitignore 生成 CSS 文件。 在 Git 中添加 CSS 文件的问题在于它们只是多余的。public/stylesheets
我目前正在尝试编写一个 Maven 插件,它应该能够在“生成资源”阶段创建/处理一些资源文件。一切正常,但在此过程中我的插件需要读取一些其他文件作为输入,所以我决定使用 Apache Maven Fi
我是一名优秀的程序员,十分优秀!