ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:17.94KB ,
资源ID:10560165      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10560165.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(迅雷种子文件解析Torrent 文件.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

迅雷种子文件解析Torrent 文件.docx

1、迅雷种子文件解析Torrent 文件对于这个类在解析Torrent 文件时候可能有错误,请大家指正。先把文件解析的类贴出来,连接有空再发把。使用TorrentFile File = new TorrentFile(openFileDialog1.FileName);File.TorrentFileInfoClass 文件信息File.TorrentAnnounceList 服务器列表全部代码using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using System

2、.Collections;namespace Zgke.OtherFile / / Torrent文件 / ZgkeS / 2008-08-28 / public class TorrentFile #region 私有字段 private string _OpenError = ; private bool _OpenFile = false; private string _TorrentAnnounce = ; private IList _TorrentAnnounceList = new List(); private DateTime _TorrentCreateTime = ne

3、w DateTime(1970,1,1,0,0,0); private long _TorrentCodePage = 0; private string _TorrentComment = ; private string _TorrentCreatedBy = ; private string _TorrentEncoding = ; private string _TorrentCommentUTF8 = ; private IList _TorrentFileInfo = new List(); private string _TorrentName = ; private strin

4、g _TorrentNameUTF8 = ; private long _TorrentPieceLength = 0; private byte _TorrentPieces; private string _TorrentPublisher = ; private string _TorrentPublisherUTF8 = ; private string _TorrentPublisherUrl = ; private string _TorrentPublisherUrlUTF8 = ; private IList _TorrentNotes = new List(); #endre

5、gion #region 属性 / / 错误信息 / public string OpenError set _OpenError = value; get return _OpenError; / / 是否正常打开文件 / public bool OpenFile set _OpenFile = value; get return _OpenFile; / / 服务器的URL(字符串) / public string TorrentAnnounce set _TorrentAnnounce = value; get return _TorrentAnnounce; / / 备用tracker

6、服务器列表(列表) / public IList TorrentAnnounceList set _TorrentAnnounceList = value; get return _TorrentAnnounceList; / / 种子创建的时间,Unix标准时间格式,从1970 1月1日 00:00:00到创建时间的秒数(整数) / public DateTime TorrentCreateTime set _TorrentCreateTime = value; get return _TorrentCreateTime; / / 未知数字CodePage / public long Tor

7、rentCodePage set _TorrentCodePage = value; get return _TorrentCodePage; / / 种子描述 / public string TorrentComment set _TorrentComment = value; get return _TorrentComment; / / 编码方式 / public string TorrentCommentUTF8 set _TorrentCommentUTF8 = value; get return _TorrentCommentUTF8; / / 创建人 / public strin

8、g TorrentCreatedBy set _TorrentCreatedBy = value; get return _TorrentCreatedBy; / / 编码方式 / public string TorrentEncoding set _TorrentEncoding = value; get return _TorrentEncoding; / / 文件信息 / public IList TorrentFileInfo set _TorrentFileInfo = value; get return _TorrentFileInfo; / / 种子名 / public stri

9、ng TorrentName set _TorrentName = value; get return _TorrentName; / / 种子名UTF8 / public string TorrentNameUTF8 set _TorrentNameUTF8 = value; get return _TorrentNameUTF8; / / 每个块的大小,单位字节(整数) / public long TorrentPieceLength set _TorrentPieceLength = value; get return _TorrentPieceLength; / / 每个块的20个字节

10、的SHA1 Hash的值(二进制格式) / private byte TorrentPieces set _TorrentPieces = value; get return _TorrentPieces; / / 出版 / public string TorrentPublisher set _TorrentPublisher = value; get return _TorrentPublisher; / / 出版UTF8 / public string TorrentPublisherUTF8 set _TorrentPublisherUTF8 = value; get return _

11、TorrentPublisherUTF8; / / 出版地址 / public string TorrentPublisherUrl set _TorrentPublisherUrl = value; get return _TorrentPublisherUrl; / / 出版地址 / public string TorrentPublisherUrlUTF8 set _TorrentPublisherUrlUTF8 = value; get return _TorrentPublisherUrlUTF8; / / NODES / public IList TorrentNotes set

12、_TorrentNotes = value; get return _TorrentNotes; #endregion public TorrentFile(string FileName) System.IO.FileStream TorrentFile = new System.IO.FileStream(FileName, System.IO.FileMode.Open); byte TorrentBytes = new byteTorrentFile.Length; TorrentFile.Read(TorrentBytes, 0, TorrentBytes.Length); Torr

13、entFile.Close(); if (char)TorrentBytes0 != d) if (OpenError.Length = 0) OpenError = 错误的Torrent文件,开头第1字节不是100; return; GetTorrentData(TorrentBytes); #region 开始读数据 / / 开始读取 / / private void GetTorrentData(byte TorrentBytes) int StarIndex = 1; while (true) object Keys = GetKeyText(TorrentBytes, ref Sta

14、rIndex); if (Keys = null) if (StarIndex = TorrentBytes.Length) OpenFile = true; break; if (GetValueText(TorrentBytes, ref StarIndex, Keys.ToString().ToUpper() = false) break; #endregion / / 读取结构 / / / / / private bool GetValueText(byte TorrentBytes,ref int StarIndex, string Keys) switch (Keys) case

15、ANNOUNCE: TorrentAnnounce = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case ANNOUNCE-LIST: int ListCount = 0; ArrayList _TempList=GetKeyData(TorrentBytes, ref StarIndex, ref ListCount); for (int i = 0; i != _TempList.Count; i+) TorrentAnnounceList.Add(_TempListi.ToString(); break; ca

16、se CREATION DATE: object Date = GetKeyNumb(TorrentBytes, ref StarIndex).ToString(); if (Date = null) if (OpenError.Length = 0) OpenError = CREATION DATE 返回不是数字类型; return false; TorrentCreateTime = TorrentCreateTime.AddTicks(long.Parse(Date.ToString(); break; case CODEPAGE: object CodePageNumb = GetK

17、eyNumb(TorrentBytes, ref StarIndex); if (CodePageNumb = null) if (OpenError.Length = 0) OpenError = CODEPAGE 返回不是数字类型; return false; TorrentCodePage = long.Parse(CodePageNumb.ToString(); break; case ENCODING: TorrentEncoding = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case CREATED B

18、Y: TorrentCreatedBy = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case COMMENT: TorrentComment = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case COMMENT.UTF-8: TorrentCommentUTF8 = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case INFO: int FileListCount

19、= 0; GetFileInfo(TorrentBytes, ref StarIndex, ref FileListCount); break; case NAME: TorrentName = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case NAME.UTF-8: TorrentNameUTF8 = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case PIECE LENGTH: object PieceLengthNumb = GetKe

20、yNumb(TorrentBytes, ref StarIndex); if (PieceLengthNumb = null) if (OpenError.Length = 0) OpenError = PIECE LENGTH 返回不是数字类型; return false; TorrentPieceLength = long.Parse(PieceLengthNumb.ToString(); break; case PIECES: TorrentPieces = GetKeyByte(TorrentBytes, ref StarIndex); break; case PUBLISHER: T

21、orrentPublisher = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case PUBLISHER.UTF-8: TorrentPublisherUTF8 = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case PUBLISHER-URL: TorrentPublisherUrl = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case PUBLISHER-URL

22、.UTF-8: TorrentPublisherUrlUTF8 = GetKeyText(TorrentBytes, ref StarIndex).ToString(); break; case NODES: int NodesCount = 0; ArrayList _NodesList = GetKeyData(TorrentBytes, ref StarIndex, ref NodesCount); int IPCount= _NodesList.Count/2; for (int i = 0; i != IPCount; i+) TorrentNotes.Add(_NodesListi

23、 * 2 + : + _NodesList(i * 2) + 1); break; default: return false; return true; #region 获取数据 / / 获取列表方式 I1:Xe=X 会调用GetKeyText / / / / private ArrayList GetKeyData(byte TorrentBytes, ref int StarIndex, ref int ListCount) ArrayList _TempList = new ArrayList(); while (true) string TextStar = Encoding.UTF

24、8.GetString(TorrentBytes, StarIndex, 1); switch (TextStar) case l: StarIndex+; ListCount+; break; case e: ListCount-; StarIndex+; if (ListCount = 0) return _TempList; break; case i: _TempList.Add(GetKeyNumb(TorrentBytes,ref StarIndex).ToString(); break; default: object ListText = GetKeyText(TorrentB

25、ytes, ref StarIndex); if (ListText != null) _TempList.Add(ListText.ToString(); else if (OpenError.Length = 0) OpenError = 错误的Torrent文件,ANNOUNCE-LIST错误; return _TempList; break; / / 获取字符串 / / / / private object GetKeyText(byte TorrentBytes, ref int StarIndex) int Numb = 0; int LeftNumb = 0; for (int i = StarIndex; i != TorrentBytes.Length; i+) if (char)TorrentBytesi = :) break; if (char)TorrentBytesi = e) LeftNumb+; continue; Numb+; StarIndex += LeftNumb; string TextNumb = Encodi

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1