我尝试下载并阅读文件(pdf/epub)。 我已经实现下载并将文件保存在以下路径中。
下载路径为-文件路径
/Users/apple/Library/Application Support/iPhone Simulator/7.1/Applications/B5C69537-DBAA-45DA-BDF3-84D0F038378D/Documents/3471.epub
但我无法从同一路径读取。我正在使用下面的代码来读取文件路径。
NSString *testpath =[[NSBundle mainBundle] pathForResource:@"3471" ofType:@"epub"];
最佳答案
NSBundle mainBundle
用于添加到项目文件夹中的文件。
如果您需要查找保存到文档文件夹中的任何下载文件,请尝试
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *testpath = [documentsDirectory stringByAppendingPathComponent:filename];
关于ios - 如何从ios中的路径读取下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27222753/