資源簡介
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(“未能找到文件下載服務(wù)器或下載文件,請?zhí)砣胝_下載地址!“);
????????????}
????????????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?????????????{
????????????????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)
????????{
??????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????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個(gè)文件信息
評論
共有 條評論