使用.NET从premiumbook帐户下载文件

时间:2010-03-18 15:56:43

标签: c# download rapidshare

如何从我的来源登录高级电子邮件帐户? 我试过这个,但它不起作用:

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");

有没有简单的方法直接从免费下载文件下载文件?

3 个答案:

答案 0 :(得分:3)

使用Fiddler查看发送的内容。然后重建查询。

下载管理器的日志也可能提供一些提示。

答案 1 :(得分:2)

Simple rapidshare class允许您在不重新发明轮子的情况下执行任务...否则请检查来自“免费软件”的API。

答案 2 :(得分:2)

有我的解决方案。像魅力一样工作:

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));
        }
相关问题