Click here to Skip to main content
12,457,493 members (55,651 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
I try to create a downlaoder in c# wich crashes because of an error i dont understand. i got the code from another site and copied it exactly to try it out but it doesnt work for me. my script:

private void button4_Click(object sender, EventArgs e)
       {
               progressBar.Visible = true;
               WebClient webClient = new WebClient();
               webClient.DownloadFile("http://www.spadille.net/aos075install.msi", @"C:\aos075install.msi");
               webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
               webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
               private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
                   {
                       progressBar.Value = e.ProgressPercentage;
                   }
 
               private void Completed(object sender, AsyncCompletedEventArgs e)
                   {
                       MessageBox.Show("Download Abgeschlossen!");
                       progressBar.Visible = false;
                       System.Diagnostics.Process.Start("\\aos075install.msi");
                   }
 
               private void button5_Click(object sender, EventArgs e)
                   {
                       System.Diagnostics.Process.Start("\\Ace of Spades\\readme.txt");
                   }
 
       }

the link to the original:
http://www.csharp-examples.net/download-files/[^]

thanks for help!

Sorry for not posting the exact error but its in german so it wont help most of you, but if i translate it it's like: Unhandled WebException - Exceptional Error During a Web cleint demand.
Posted 4-Feb-13 6:42am
Updated 5-Feb-13 5:20am
v2
Comments
richcb 4-Feb-13 12:48pm
   
You will need to post the error message so that we can see it. Use the "Improve Question" widget to add that info please.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

webClient.DownloadFile("http://www.spadille.net/aos075install.msi", @"C:\aos075install.msi");


Make sure this path is correct and a file actually exists at that path.
  Permalink  
Comments
FrontFreak 5-Feb-13 11:20am
   
thats the point: at the site i looked it looked as if the second half (@"C:\file.msi") was just where to downlaod the file and how to name it, thats what i thaght it would mean. I also tried not to add any file name at all but just the path, didnt work neither. Ill try to name another file like that and add it there so that the download would work then but that'd be rather strange! XD
FrontFreak 5-Feb-13 11:24am
   
Well, actually worked... so i'd have to first create a file named like that and then download and replace it... well that actually solves the problem. But is there a easier solution to download the file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100