Skip to content

Instantly share code, notes, and snippets.

@JoshVarty
Created December 11, 2013 17:08
Show Gist options
  • Save JoshVarty/7914461 to your computer and use it in GitHub Desktop.
Save JoshVarty/7914461 to your computer and use it in GitHub Desktop.
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
string HCDownloadURL = String.Format("http://www.survivaloperations.net/client/hardcorps/HardCorps.zip");
WebClient Download_Client = new WebClient();//Declaring the webclient as Download_Client
Download_Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);//the event handler
Download_Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);// " "
Download_Client.DownloadFileAsync(new Uri(HCDownloadURL.Trim().ToString()), "test.zip");// " "
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
pbDownloader.Value = e.ProgressPercentage;//setting the progressbar value as downloadprogress
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
pbDownloader.Value = (0);//resetting the progressbar
//file is saved in /bin/x86/debug
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment