Click here to Skip to main content
13,042,630 members (76,190 online)
Rate this:
Please Sign up or sign in to vote.
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:

private void button4_Click(object sender, EventArgs e)
               progressBar.Visible = true;
               WebClient webClient = new WebClient();
               webClient.DownloadFile("", @"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;
               private void button5_Click(object sender, EventArgs e)
                       System.Diagnostics.Process.Start("\\Ace of Spades\\readme.txt");

the link to the original:[^]

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
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
Please Sign up or sign in to vote.

Solution 1

webClient.DownloadFile("", @"C:\aos075install.msi");

Make sure this path is correct and a file actually exists at that path.
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.170713.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2017
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