我正在尝试通过C ++ .NET从rapidshare下载文件,但我遇到了一些麻烦。
地址曾经是“https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi”,但不再有效,有谁知道新的地址是什么? 代码工作但文件大小总是1KB,我不认为它连接到正确的服务器。
private: void downloadFileAsync(String^ fileUrl)
{
String^ uriString;
uriString = "https://ssl.rapidshare.com/premzone.html";//"https://ssl.rapidshare.com";
NameValueCollection^ postvals = gcnew NameValueCollection();
postvals->Add("login", "bob");
postvals->Add("password", "12345");
// postvals->Add("uselandingpage", "1");
WebClient^ myWebClient = gcnew WebClient();
array<unsigned char>^ responseArray = gcnew array<unsigned char>(10024);
responseArray = myWebClient->UploadValues(uriString, "POST", postvals);
StreamReader^ strRdr = gcnew StreamReader(gcnew MemoryStream(responseArray));
String^ cookiestr = myWebClient->ResponseHeaders->Get("Set-Cookie");
myWebClient->Headers->Add("Cookie", cookiestr);
//myWebClient->DownloadFileCompleted += gcnew AsyncCompletedEventHandler(myWebClient->DownloadFileCompleted);
myWebClient->DownloadFileAsync(gcnew Uri(fileUrl),"C:\\rapid\\"+Path::GetFileName(fileUrl));
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
downloadFileAsync("http://rapidshare.com/files/440636806/ArcadeBackground.png");
}
答案 0 :(得分:2)
Rapidshare最近彻底改革了他们的结构。那1kb文件可能是HTML文本,告诉你你做错了什么。
修改强>
您使用的是Rapishare API吗?因为您的代码看起来并不像我在其文档页面上看到的那样。