using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace DownlaodFile
{
public partial class Form1 : Form
{
System.Net.WebClient c ;
public Form1()
{
InitializeComponent();
c = new System.Net.WebClient();
c.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(c_DownloadProgressChanged);
c.DownloadFileCompleted += new AsyncCompletedEventHandler(c_DownloadFileCompleted);
c.Proxy=WebRequest.DefaultWebProxy;
c.Proxy.Credentials = new NetworkCredential("admin", "admin_password", "domain");
}
void c_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("ok");
}
private void btnDownload_Click(object sender, EventArgs e)
{
c.DownloadFileAsync(new Uri(txtUrl.Text), @"d:"t.dat");
}
void c_DownloadProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void btnQuit_Click(object sender, EventArgs e)
{
if (c!=null)
{
c.CancelAsync();
}
Close();
}
}
}