I am trying to downloa开发者_Python百科d a file from rapidshare via C++ .NET but I'm having a bit of trouble.
The address used to be "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi" but that no longer works, does anyone know what the new one is? The code works but the file size is always 1KB, I don't think its connecting to the right server.
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");
}
Rapidshare has completely overhauled their structure lately. That 1kb file is probably HTML text telling you what you're doing wrong.
Edit
Are you using the Rapishare API? Because your code doesn't look at all like what I see on their documentation page.
精彩评论