【发布时间】:2012-07-23 13:07:54
【问题描述】:
我是 iPhone 新手,
我制作了一个应用程序,当用户下载任何内容时,它会被下载到DocumentDirectory
我想在DocumentDirectory创建的文件夹中下载
如何做到这一点?
我想我会下载文件到我的DocumentDirectory,然后我会将该文件移动到我在DocumentDirectory 内的文件夹中。
这是个好习惯吗?
这是我的代码 sn-p,但我仍然无法移动我的文件。
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *file = [NSString stringWithString:[url absoluteString]];
NSURL *fileURL = [NSURL URLWithString:file];
NSURLRequest *req = [NSURLRequest requestWithURL:fileURL];
[NSURLConnection connectionWithRequest:req delegate:self];
NSString *DestPath=[[[SourcePath stringByAppendingString:@"/"]stringByAppendingString:BookCateg]stringByAppendingString:@"/"];
if ([fm copyItemAtPath:SourcePath toPath:DestPath error:&error])
{
NSLog(@"Success !");
}
else{
NSLog(@"Fail to Move!");
}
}
我的日志显示Fail to Move!
我们将不胜感激。
【问题讨论】:
标签: iphone ios ipad nsfilemanager nsdocumentdirectory