可能一下代碼會比較長,看起來比較麻煩,我大概說一下用法,這個類我自己測試過是沒有問題的
代碼
1 Download load = new Download(dr["SourceUrl"].ToString());
2 load.ThreadCount = 5;
3 load.Filename = dr["FileName"].ToString();
4 load.DirectoryName = dr["Dest"].ToString();
5 load.Progress += new Download.ProgressEventHandler(load_Progress);
6 load.Finished += new Download.FinishedEventHandler(load_Finished);
7 load.Speed += new Download.SpeedHandler(load_Speed);
8 load.Start();
下面是全部代碼
Download
1 public class Download
2 {
3 public Download(string url)
4 {
5 this.Url = url;
6 this.ThreadCount = 5;
7 }
8
9 #region 委托
10
11 public delegate void ExceptionEventHandler(Download sender, Exception e);
12 public delegate void ConnectedEventHandler(Download sender, string filename, string contentType);
13 public delegate void ProgressEventHandler(Download