Click here to Skip to main content
Rate this: bad
good
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 7:42am
Edited 5-Feb-13 6:20am
v2
Comments
richcb at 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 at 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 at 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
0 OriginalGriff 390
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
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