尝试从Rapidshare下载文件时出现问题 [英] Problem with attempting to download a file from rapidshare

查看:95
本文介绍了尝试从Rapidshare下载文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,所以我一直在网上浏览各种代码块,而我似乎无法使它起作用:(

请注意,我不太熟练使用C#进行编程,但是我确实有很多知识.

好的,基本上我想做的就是使用我的高级帐户从Rapidshare下载文件,并且看起来不错,直到您尝试打开该文件.

下载后,我尝试打开该文件,它始终会显示以下错误:

"NTVDM CPU遇到了一条非法指令.
CS:05a IP:fffe OP:ff ff 00 00 00选择关闭"以终止应用程序."

现在,该弹出窗口的标题为"16位MS-DOS子系统",因此我假设我下载的文件被视为16位.其实不是,这实际上是我今年早些时候制作的一个小程序.

这是我用来执行下载的代码块:

Alright so I''ve been playing around with various blocks of code from around the web and I can''t seem to get this to work :(

Note I am not that skilled in programming in C# however I do have quite a bit of knowledge.

Okay so basically what I want to do is download a file from rapidshare using my premium account, and it seems to work fine, untill you try to open the file.

After the download, I attempt opening the file and it always gives me this error:

"The NTVDM CPU has encountered an illegal instruction.
CS:05a IP:fffe OP:ff ff 00 00 00 Choose ''Close'' to terminate the application."

Now the title of this popup us "16 bit MS-DOS Subsystem", so I''m assuming the file i''ve download is being regarded as being 16 bit. It isn''t though, it''s actually a small program that I made earlier this year.

Here is the chunk of code that I''m using to perform the download:

private void downloadFile()
{
    string url
        =                @"http://rapidshare.com/files/412151386/GE_Item_Finder.exe";

    // Create an instance of WebClient
    WebClient client = new WebClient();
    client.Credentials = new NetworkCredential("username", "password");//I fill in these with my own details



    // Hookup DownloadFileCompleted Event
    client.DownloadFileCompleted +=
        new AsyncCompletedEventHandler(client_DownloadFileCompleted);

    // Start the download and copy the file to c:\temp
    Uri fileUri = new Uri(url);
    client.DownloadFile(fileUri, "C:\\Temp\\" + Path.GetFileName(url));
    //System.Threading.Thread.Sleep(100);
}

void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
    MessageBox.Show("File downloaded");
}




就是这样,如果有人可以告诉我我做错了什么,也许可以解决我的问题,那将很有用.

在此先感谢:)
-Raz




Well that''s it, if anybody could please tell me what I''m doing wrong, and perhaps offer a solution to my problem, it would be of great use.

Thanks in advance :)
- Raz

推荐答案

我必须做与此类似的事情,不能保证方法相同,但这也应该起作用.第二部分的替代方法(我不确定此处)是使用另一个HttpWebRequest而不是webclient.但是,当我浏览该网址时,您输入的网址会提示我登录"或使用免费版本"-即,您不能仅浏览该网址并获取文件.重要的是要注意,从.NET发出这些请求时,内部浏览器不会与IE或您可能使用的任何其他浏览器共享您的会话信息.


I had to do something similar to this, can''t gaurantee the approach is the same but this should work as well. The alternative to the 2nd part (I''m unsure here) is to use another HttpWebRequest instead of webclient. but when I surf to the url you gave it prompts me to "login" or use the "free version" - i.e. you can''t just surf the url and get the file. It''s important to note that when doing these requests from .NET the internal browser does not share your session information with IE or any other browser you may be using.


CookieContainer cookies = new CookieContainer();
string username = "UserName";
string password = "Password";
string outputStr = string.Empty;
string mainUrl = @"http://www.rapidshare.com"; // Will need to determine the exact login url
string downloadUrl = @"http://rapidshare.com/files/412151386/GE_Item_Finder.exe";
HttpWebRequest webreq = HttpWebRequest.Create(mainUrl) as HttpWebRequest;
webreq.Method = "POST";
webreq.ContentType = "application/x-www-form-urlencoded";
webreq.CookieContainer = cookies;
string postData = "usrlogin=" + username + "&usrpassword=" + password; // Will need to view source on the login page to find the values to post
StreamWriter reqWriter = new StreamWriter(webreq.GetRequestStream());
reqWriter.Write(postData);
reqWriter.Close();
// I would normally get the response to confirm I've logged in
HttpWebResponse webResp = webreq.GetResponse() as HttpWebResponse;
StreamReader respRDR = new StreamReader(webResp.GetResponseStream());
outputStr = respRDR.ReadToEnd();
respRDR.Close();
webResp.Close();
respRDR.Close();
using (WebClient client = new WebClient())
{
    client.Headers.Add(cookies.GetCookieHeader(new Uri(mainUrl));
    client.DownloadFile(downloadUrl, @"c:\GE_Item_Finder.exe");
}


这篇关于尝试从Rapidshare下载文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆