资源简介
C# 仿迅雷源码
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
namespace ThunderSpeed
{
public class DownLoad
{
private readonly AutoResetEvent are = new AutoResetEvent(true);
public List G_thread_Collection = new List();
private bool b_thread;
public bool complete = false;
public string downloadUrl;
public DateTime dtbegin;
public string fileNameAndPath;
public string filename;
public string filepath;
public long filesize;
public List lbo = new List();
public List lli = new List();
public bool state = false;
public bool stop = false;
public bool stop2 = false;
public int xiancheng;
public DownLoad(string filename string filepath string downloadurl string FileNameAndPath int xiancheng)
{
this.filename = filename;
this.filepath = filepath;
downloadUrl = downloadurl;
fileNameAndPath = FileNameAndPath;
this.xiancheng = xiancheng;
dtbegin = DateTime.Now;
}
public void StartLoad()
{
long filelong = 0;
try
{
HttpWebRequest hwr = (HttpWebRequest) WebRequest.Create(downloadUrl);
HttpWebResponse hwp = (HttpWebResponse) hwr.GetResponse();
filelong = hwp.ContentLength;
b_thread = GetBool(downloadUrl);
}
catch (WebException we)
{
throw new WebException(“未能找到文件下载服务器或下载文件,请添入正确下载地址!“);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
filesize = filelong;
int meitiao = (int) filelong/xiancheng;
int yitiao = (int) filelong%xiancheng;
Locations ll = new Locations(0 0);
lbo = new List();
for (int i = 0; i < xiancheng; i++)
{
ll.Start = i != 0 ? ll.End + 1 : ll.End;
ll.End = i == xiancheng - 1
? ll.End + meitiao + yitiao
: ll.End + meitiao;
Thread th = new Thread(GetData);
th.Name = i.ToString();
th.IsBackground = true;
th.Start(ll);
lli.Add(new Locations(ll.Start ll.End downloadUrl filename filesize
new Locations(ll.Start ll.End)));
ll = new Locations(ll.Start ll.End);
G_thread_Collection.Add(th);
lbo.Add(false);
}
HeBingFile();
}
public void GetData(object l)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11510 2012-05-17 10:38 softhy.net\ThunderSpeed\ThunderSpeed\DownLoad.cs
文件 3329 2012-05-20 10:26 softhy.net\ThunderSpeed\ThunderSpeed\LoadStart.cs
文件 7336 2012-05-17 10:23 softhy.net\ThunderSpeed\ThunderSpeed\LoadStart.Designer.cs
文件 6022 2010-05-04 23:18 softhy.net\ThunderSpeed\ThunderSpeed\LoadStart.resx
文件 1505 2012-05-20 10:26 softhy.net\ThunderSpeed\ThunderSpeed\Locations.cs
文件 26877 2012-05-17 10:38 softhy.net\ThunderSpeed\ThunderSpeed\Main_form.cs
文件 11992 2012-05-17 10:35 softhy.net\ThunderSpeed\ThunderSpeed\Main_form.Designer.cs
文件 6191 2010-04-23 16:50 softhy.net\ThunderSpeed\ThunderSpeed\Main_form.resx
文件 3262 2010-01-27 21:08 softhy.net\ThunderSpeed\ThunderSpeed\mingri.ico
文件 403 2012-05-20 10:25 softhy.net\ThunderSpeed\ThunderSpeed\Program.cs
文件 577 2012-05-17 10:38 softhy.net\ThunderSpeed\ThunderSpeed\Properties\AssemblyInfo.cs
文件 7526 2012-05-17 10:18 softhy.net\ThunderSpeed\ThunderSpeed\Properties\Resources.Designer.cs
文件 10471 2012-05-17 10:18 softhy.net\ThunderSpeed\ThunderSpeed\Properties\Resources.resx
文件 1097 2012-05-17 09:35 softhy.net\ThunderSpeed\ThunderSpeed\Properties\Settings.Designer.cs
文件 249 2012-05-17 09:49 softhy.net\ThunderSpeed\ThunderSpeed\Properties\Settings.settings
文件 10361 2010-01-18 18:48 softhy.net\ThunderSpeed\ThunderSpeed\Resources\caidan.jpg
文件 96878 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\LoadStart.jpg
文件 228720 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\Main_Form.jpg
文件 5726 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_begin.png
文件 5540 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_begin2.png
文件 5032 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_cancel.png
文件 5307 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_cancel2.png
文件 3583 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_close.png
文件 6129 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_continue.png
文件 6150 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_continue2.png
文件 6206 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_delete.png
文件 6110 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_delete2.png
文件 6197 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_new.png
文件 6127 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_new2.png
文件 5919 2010-04-23 04:59 softhy.net\ThunderSpeed\ThunderSpeed\Resources\pbox_pause.png
............此处省略15个文件信息
- 上一篇:C#实验—接口:正方形、三角形、圆形求面积
- 下一篇:c#实现的简单画图程序源代码
相关资源
- c#实现的简单画图程序源代码
- C#实验—接口:正方形、三角形、圆形
- C#进销存源码
- 一个基于C# +SQL的学生成绩管理系统。
- 简单考试系统
- 快速傅里叶变换C#实现
- C#.NET编写的写字板程序
- AE开发统计模块C#
- C#集合性能测试
- c#银行家算法 有界面
- C# Windows窗体程序 连接 Access数据库增
- c# 语音识别 智能机器人 语音问答
- C# VBIDE引用
- C# 数字图像处理 有关遥感图像处理的
- winform(c#) DataGridView控件多维合并表
- c# wpf 实现文件上传功能
- c# 远程监控onenet.zip
- 教务课程管理系统Microsoft Visual Studi
- 学生选课系统源代码asp.net + c# + acce
- C#调用金蝶登录界面(反射)及使用说
- C#+SQL数据库开发的网上书店系统
- Microsoft.Office.Interop.Word -C#操作word
- 图书馆系统C#
- C#计算器堆栈版
- C#实现的电子相册源代码
- C#做的简单的Undo、Redo功能的实现
- C#串口编程
- C#图片转换成二进制流并且保存到sq
- C#使用SMTP服务器发送邮件
- C# chart实时数据显示简单工程文件
评论
共有 条评论