我是 iPhone 新手,
我制作了应用程序,当用户下载任何内容时,它会被下载到DocumentDirectory
我想在我创建的文件夹中下载DocumentDirectory
如何做到这一点?
我想我会把文件下载到我的DocumentDirectory
,然后我会将该文件移动到我的文件夹中DocumentDirectory
。
这是好习惯吗?
这是我的代码片段,但我仍然无法移动我的文件。
- (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!
任何帮助将不胜感激。