0

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

}
4

1 回答 1

2

Rapidshare 最近彻底改革了他们的结构。那个 1kb 的文件可能是 HTML 文本,告诉你你做错了什么。

编辑

您在使用Rapishare API吗?因为您的代码与我在他们的文档页面上看到的完全不同。

于 2011-01-03T21:20:56.977 回答