资源简介
Torrent.cs
代码片段和文件信息
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Text.Regularexpressions;
namespace System
{
public class Torrent
{
#region 私有成员字段
string announce = ““;
Listject> announcelist = new Listject>();
string comment = ““;
string commentutf8 = ““;
string createdby = ““;
DateTime creationdate = new DateTime(1970 1 1 0 0 0);
string encoding = ““;
#endregion
#region 属性
public string Announce { get { return this.announce; } set { this.announce = value; } }
public Listject> AnnounceList { get { return this.announcelist; } set { this.announcelist = value; } }
public string Comment { get { return this.comment; } set { this.comment = value; } }
public string CommentUTF8 { get { return this.commentutf8; } set { this.commentutf8 = value; } }
public string CommentBy { get { return this.createdby; } set { this.createdby = value; } }
public DateTime CreationDate { get { return this.creationdate; } set { this.creationdate = value; } }
public string TorrentEncoding { get { return this.encoding; } set { this.encoding = value; } }
#endregion
FileStream fs;
BinaryReader br;
public Torrent(string path)
{
fs = new FileStream(path FileMode.Open);
br = new BinaryReader(fs);
byte[] buf = new byte[1];
string str = ““;
buf[0] = br.ReadByte();
str = Encoding.UTF8.GetString(buf 0 1);
if (str == “d“)
{
this.ReadAll();
}
else
{
Exception e = new Exception(“无法解析此文件“);
throw e;
}
}
int ReadInt(BinaryReader br)
{
return 0;
}
string ReadString(BinaryReader br)
{
byte[] buf = new byte[1];
string str = ““;
buf[0] = br.ReadByte();
str = Encoding.UTF8.GetString(buf);
Regex reg = new Regex(“^[0-9]*$“);
if (reg.Match(str).Value != string.Empty)
{
buf[0] = br.ReadByte();
string tmpstr = Encoding.UTF8.GetString(buf);
while (tmpstr != “:“)
{
str += tmpstr;
buf[0] = br.ReadByte();
tmpstr = Encoding.UTF8.GetString(buf);
}
int j = Convert.ToInt32(str);
str = ““;
byte[] buf2 = new byte[j];
for (int i = 0; i < j; i++)
{
buf2[i] = br.ReadByte();
}
str = Encoding.UTF8.GetString(buf2);
return str;
}
else
{
- 上一篇:C#获取图片并保存到本地
- 下一篇:C#使用HttpClient
相关资源
- PDF文件 阅读控件 (VeryPDF PDFView OCX)
- C#自定义控件案例--美化GroupBox.rar
- BouncyCastle C#源码
- C#高级编程(第10版) 百度网盘资源
- Unity5实战:使用C#和Unity开发多平台游
- zw_ASP.NET通用权限管理系统源代码含文
- 24652561RevitWPFAddin.zip
- ASP.NET网站建设实战--人民邮电出版社
- 传智播客ASP.NET[特供第三季].txt
- Winform通用经典快速开发CS框架-outloo
- C#爬取音乐源码.zip
- Rudin著第一册—阅读密码www.zasp.net_仅
- PracticalWPFChartsandGraphics.rar
- cb-9X-C#winform实现PDF阅读功能.rar
- sU-WV-C#比赛记时软件.rar
- u5-TW-C#打印操作--使用GDI绘图打印学生
- z1_C#打印操作--使用GDI绘图打印学生信
- C#打印操作--使用GDI绘图打印学生信息
- asp.net网上教学系统全站程序.zip
- C#管理学生考勤及作业登记系统
- 2321363LearnWPFMVVM-XAMLCandtheMVVMpattern.pdf
- 商品销售管理系统C#源码
- 松下PLC与C#上位机通讯库含程序.rar
- C#图书管理系统.rar
- C#基于BouncyCastle.Crypto的SM2_3实现导入即
- zw_WPF_开发教程(_中文版).zip
- asp.net进销存系统源码.rar
- 网上商城源码(asp.netmvc开发).rar
- 0027ASP.NET公司员工管理系统的设计与实
- asp.net捐赠慈善公益管理系统.rar
评论
共有 条评论