无法在ASIHTTPRequest中移动文件错误

时间:2010-05-18 12:25:18

标签: iphone cocoa asihttprequest

我正在使用ASIHTTPRequest从服务器下载文件,但是它给出了错误

  

无法从'/ Users / admin / Library / Application移动文件   支持/ iPhone   模拟器/ 3.1.3 /应用/ 8650FFE4-9C18-425C-9CEE-7392FD788E6D /文档/温度/ test.zip.download”   到'/ Users / admin / Library / Application Support / iPhone   模拟器/ 3.1.3 /应用/ 8650FFE4-9C18-425C-9CEE-7392FD788E6D /文档/ test.zip'

任何身体都能告诉我这个错误我的代码有什么不对......

    NSURL *url = [NSURL URLWithString:@"http://wordpress.org/latest.zip"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];

NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);

NSString *path = [NSString stringWithFormat:@"%@/test.zip", [dirArray objectAtIndex:0]];

//NSString *tempPath = [NSString stringWithFormat:@"%@test.zip", NSTemporaryDirectory()]    ;

NSString *tempPath =[NSString stringWithFormat:@"%@/temp/test.zip.download", [dirArray objectAtIndex:0]];

// The full file will be moved here if and when the request completes successfully
[request setDownloadDestinationPath:path];
[request setTemporaryFileDownloadPath:tempPath];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[[self queue] addOperation:request]; //queue is an NSOperationQueue

3 个答案:

答案 0 :(得分:1)

你在那个地方已经有了一个temp.zip吗?

答案 1 :(得分:0)

如果您没有使用setDownloadDestinationPath:的{​​{1}}方法正确设置目标路径,也会发生这种情况......

答案 2 :(得分:0)

你的电话     [request setTemporaryFileDownloadPath:tempPath]; 没有必要,而且很可能是你错误的根源。