using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net; // make sure that using System.Net; is included
using System.Diagnostics; // make sure that using System.Diagnostics; is included
namespace HttpDownloadC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
WebClient webClient = new WebClient();
private void button1_Click(object sender, EventArgs e)
{
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webclient_DownloadFileCompleted);
// start download
webClient.DownloadFileAsync(new Uri(textBox1.Text), @"C:\\MYRAR.EXE");
}
void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
double bytesIn = double.Parse(e.BytesReceived.ToString());
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = bytesIn / totalBytes * 100;
progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
}
void webclient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Saved as C:\\MYRAR.EXE", "Httpdownload");
}
}
}
Search thousands of free JavaScript snippets that you can quickly copy and paste into your web pages. Get free JavaScript tutorials, references, code, menus, calendars, popup windows, games, and much more.
Subscribe to:
Post Comments (Atom)
Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts
Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...
-
code.gs // 1. Enter sheet name where data is to be written below var SHEET_NAME = "Sheet1" ; // 2. Run > setup // // 3....
No comments:
Post a Comment