我正在尝试通过 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");
}