C#一个下载类,支持断点下载,多线程之类的
可能一下代码会比较长,看起来比较麻烦,我大概说一下用法,这个类我自己测试过是没有问题的
代码
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();
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
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
补充:软件开发 , C# ,
上一个:SqlCommandBuilder用法
下一个:基于C#的泛型编程
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,
部分文章来自网络,