How can I log to premium rapidshare account from开发者_高级运维 my source? I tryed this but it is not working:
string authInfo = "name" + ":" + "pass";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
client.Headers["Authorization"] = "Basic " + authInfo;
client.DownloadFile("url", "C:\\Temp\\aaaa.file");
OR
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("name", "pass");
client.DownloadFile("url", "C:\\Temp\\aaaa.file");
Is there any simple way how download the file directly from rapidshare premium?
Use Fiddler to see what is being sent. Then reconstruct the query.
A download manager's logs may also provide some tips.
Simple rapidshare class allows you to perform your task without re-inventing the wheel...Otherwise check the APIs from rapidshare.
There is my solution. work like a charm:
private void downloadFileAsync(string fileUrl)
{
string uriString;
uriString = "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi";
NameValueCollection postvals = new NameValueCollection();
postvals.Add("login", "aaa");
postvals.Add("password", "bbb");
postvals.Add("uselandingpage", "1");
WebClient myWebClient = new WebClient();
Byte[] responseArray = myWebClient.UploadValues(uriString, "POST", postvals);
StreamReader strRdr = new StreamReader(new MemoryStream(responseArray));
string cookiestr = myWebClient.ResponseHeaders.Get("Set-Cookie");
myWebClient.Headers.Add("Cookie", cookiestr);
myWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(myClient_DownloadFileCompleted);
myWebClient.DownloadFileAsync(new Uri(fileUrl),"C:\\Temp\\"+Path.GetFileName(fileUrl));
}
精彩评论