Updating button text while downloading a file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    Updating button text while downloading a file.

    I want the download button to update while a file download is in progress - "Connecting ", "Downloading.." , etc. But with the code below, it does not update the text. I've read about Application.DoE vents() but also heard that this isn't the best route to take? If it is OK to use Application.DoE vents(), where should I use it?

    Code:
    button1.Text = "Connecting...";
                Uri URL = new Uri("http://mahcuz.com/projectdownload/ClipboardIP/updatediplist.xml");
                try
                {
                    WebClient Client = new WebClient();
                    button1.Text = "Downloading...";
                    Client.DownloadFile(URL, Application.StartupPath + "/IP.xml");
                    button1.Text = "Finished";
                }
                catch (Exception Ex)
                {
                    button1.Text = "Failed";
                }
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I see you took a different route using the IE object instead of HttpWebRequest.

    Anyways, in that situation you described, calling button1.Update( ) (force redraw of buton1) would be more suitable then a full Application.DoE vents().

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Originally posted by Plater
      I see you took a different route using the IE object instead of HttpWebRequest.

      Anyways, in that situation you described, calling button1.Update( ) (force redraw of buton1) would be more suitable then a full Application.DoE vents().
      Yeh, I couldn't find an example of using HttpWebRequest for a file download.

      button1.Update( ) works wonders.

      Thanks, Plater.

      Comment

      Working...