0

I am trying to download 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");

}
egrunin
  • 24,650
  • 8
  • 50
  • 93
cruisx
  • 1
  • 1
  • 1
    What's the content of that 1kB file? I assume it's some kind of error that might help you – CodesInChaos Jan 03 '11 at 20:57
  • This language is called C++/CLI, not C++.NET and definitely not "Managed C++". We use the last term only as shorthand for "Managed Extensions for C++" which was part of VS2002 and VS2003 and died a well-deserved death when C++/CLI came out in VS2005. – Ben Voigt Jan 03 '11 at 23:35

1 Answers1

2

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.

egrunin
  • 24,650
  • 8
  • 50
  • 93
  • well in the folder the file appears as ArcadeBackground.png but when i open it i get the pic is corrupted/ damaged error. – cruisx Jan 03 '11 at 22:50
  • if i open it with notepad i get – cruisx Jan 03 '11 at 22:56
  • 2
    So it's a javascript redirect, and some of the parameters in the new query string are probably time limited. Looks like you'll have to download that first, parse the new URL, and make a second request. – Ben Voigt Jan 03 '11 at 23:34