作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我下载一本书的代码
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle]resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];
NSString *filePath= [resourceDocPath stringByAppendingPathComponent:_bookname];//in _bookname i am already getting the value ,say abcd.pdf
NSLog(@"The bookfilepath is %@",filePath);
NSLog(@"the lenght of recieved data is %d", _recievedData.length);//here i get the correct file size also
[_recievedData writeToFile:filePath atomically:YES];
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath: filePath] == YES)
{
flag=1;
NSLog (@"File exists");
}
else
{
NSLog (@"File not found"); //always this happens in the log
}
}
filePath
处不存在文件。为什么?有趣的是 _recievedData.length
返回了正确的文件大小。
最佳答案
因为你不能写入应用程序包([[NSBundle mainBundle] resourcePath]
)。
改为写入文档文件夹。
关于ios - 无法在ios中下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30101986/
前文链接: Spring复杂的BeanFactory继承体系该如何理解? ----上 Spring复杂的BeanFactory继承体系该如何理解? ----中 Spring IoC容器 Applica
我正在努力实现这个目标 | Div | |Div nav wrapper| | logo | |con
我正在尝试从下拉菜单中的链接进行模式启动。模态似乎启动了(网站变灰),但看不到。来自不在下拉列表中的常规链接的模式工作得很好。我愚弄了 jquery,但由于我是 jquery 的新手,所以没有任何结果
我是一名优秀的程序员,十分优秀!