aRRoyo
aRRoyo

Reputation: 25

Code doesn't download the file correctly

I am trying to download IronPython with c#.

The original filesize = 15,6MB but when I click to download it gets a file which size is 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?

Upvotes: 0

Views: 111

Answers (2)

Patrick Hofman
Patrick Hofman

Reputation: 156918

You are not actually downloading the file, but the page that starts the download.

CodePlex uses a strange download javascript method. The real file is situated here: 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.

Upvotes: 3

steinar
steinar

Reputation: 9653

If you look at the HTML in question, you'll see that it starts downloading via Javascript. This code doesn't get executed by merely downloading the web page.

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

Upvotes: 0

Related Questions