Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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
Updated 5-Feb-13 5:20am
v2
Comments
Richard C Bishop 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

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.
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900