简体   繁体   English

代码未正确下载文件

[英]Code doesn't download the file correctly

I am trying to download IronPython with c#. 我正在尝试使用c#下载IronPython。

The original filesize = 15,6MB but when I click to download it gets a file which size is 16KB. 原始文件大小为15,6MB,但是当我单击下载时,它得到的文件大小为16KB。

This is my download code: 这是我的下载代码:

string[] a = lsrv.GetLinks();
string iron = a[0].ToString();

//here is my string iron = http://ironpython.codeplex.com/downloads/get/970325

using (WebClient wc = new WebClient())
{
      wc.DownloadProgressChanged += wc_DownloadProgressChanged;
      wc.DownloadFileAsync(new System.Uri(iron),
                 "C:\\Users\\Hp\\Downloads\\IronPython-2.7.5.msi");
}

What is wrong? 怎么了? Any ideas? 有任何想法吗?

You are not actually downloading the file, but the page that starts the download. 您实际上并不是在下载文件,而是开始下载的页面。

CodePlex uses a strange download javascript method. CodePlex使用奇怪的下载javascript方法。 The real file is situated here: http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=ironpython&DownloadId=970325&FileTime=130623736019230000&Build=21031 . 实际文件位于此处: http : //download-codeplex.sec.s-msft.com/Download/Release?ProjectName=ironpython&DownloadId=970325&FileTime=130623736019230000&Build=21031

If you put that in, the file will actually download. 如果您将其放入,该文件将实际下载。

If you look at the HTML in question, you'll see that it starts downloading via Javascript. 如果您查看有问题的HTML,就会看到它开始通过Javascript下载。 This code doesn't get executed by merely downloading the web page. 仅下载网页并不会执行此代码。

<script type="text/javascript">
    $(document).ready(function() {
        startDownload();
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM