It may take a long time for the code and it looks troublesome. I will give you a rough idea about the usage. I have tested this class myself.
Code 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 ();
Below is all the code
Download 1 public class Download
2 {
3 public Download (string url)
4 {
5 this. Url = url;
6 this. ThreadCount = 5;
7}
8
9 # region Delegation
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