在iPhone中,将从iOS应用下载的文件保存在哪里 [英] In iPhone, where does save a file downloaded from a iOS app
问题描述
从我的应用程序中,我可以通过NSURLConnection从服务器下载一个zip文件.在下载时,我正在将此写入文件中,以便将其保存到documentDirectory中.
From my app, I can download a zip file from a server through NSURLConnection. While I'm downloading I'm writing to this into a file, so that it will save into documentsDirectory.
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
currentDownload = [documentsDirectory stringByAppendingString:@"/Zipfile"];
NSFileHandle *fileHandle = [NSFileHandle fileHandleForWritingAtPath:currentDownload];
[fileHandle seekToEndOfFile];
[fileHandle writeData:data];
[fileHandle closeFile];
这是我用于下载及其工作的代码.如果我在模拟器中运行该应用程序,则可以在文件夹/Users/TECSOLiMac02/Library/Application Support/iPhone Simulator/6.0/Applications/9DECB1F4-C88D-4B62-BA1F-B9D5D4E421B9/Documents/Zipfile
This is the code I used for downloading and its working. If I run the app in simulator, I can see the downloaded file in MAC in the folder /Users/TECSOLiMac02/Library/Application Support/iPhone Simulator/6.0/Applications/9DECB1F4-C88D-4B62-BA1F-B9D5D4E421B9/Documents/Zipfile
我在哪里可以在iPhone/iPad上看到此下载文件?
Where can I see this downloaded file in iPhone/iPad?
推荐答案
每个应用程序都放在iPhone的沙箱中.每个应用程序都在设备的目录结构中(例如在模拟器中).
Every application is sandboxed in iPhone.Each application have it's on directory structure in device (like in simulator).
移动设备中文档目录的路径类似于:
The path of document directory in mobile is something like:
/var/mobile/Applications/AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEFFFFFF/Documents/
该目录中的文件不能被任何其他应用程序访问.所有者应用程序本身可以访问它.并可以通过代码进行访问.
The files in that directories cannot be accesses by any other applications. It can be accessed by the owner application itself. And can be accessed through code.
如果要查看文档目录中的文件,则需要在info.plist中设置 UIFileSharingEnabled
键
If you want to see the files in document directory you need to set the UIFileSharingEnabled
key in the info.plist
应用程序文档目录中的文件将在iTunes上显示,如下所示:
The files in the application's document directory will be displayed on the itunes as like:
请查看 教程 .
Please check the tutorial for details.
这篇关于在iPhone中,将从iOS应用下载的文件保存在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!