0
の表示リストに私は、文字列http://pastebin.com/upTpYUTTのリストを持って、私はこれを行う方法をhttp://pastebin.com/aML6V3uV このように、私はグループと表示リストにしたい、このコードどのグループと文字列
public class tdata
{
public string fpath { get; set; }
public string fsize { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
TorrentFile torrent = Bencode.DecodeTorrentFile("mik.torrent");
/*BString announce = (BString)torrent["encoding"];
object dat = (object)torrent["creation date"];
richTextBox1.SelectionFont = new Font("Tahoma", 11, FontStyle.Regular);
BDictionary info = torrent.Info;
string mk = info["length"].ToString();
long size = Convert.ToInt64(mk);*/
//richTextBox1.Text = lista.Count.ToString();
List<tdata> name = new List<tdata>();
BList files = (BList)torrent.Info["files"];
foreach (BDictionary file in files)
{
// File size in bytes (BNumber has implicit conversion to int and long)
int size = (BNumber)file["length"];
// List of all parts of the file path. 'dir1/dir2/file.ext' => dir1, dir2 and file.ext
BList path = (BList)file["path"];
//int i = 0;
String filepath = String.Empty;
foreach (IBObject f in path)
{
filepath += @"\" + f.ToString();
}
if (filepath.Substring(0,1) == @"\")
{
filepath = filepath.Substring(1);
}
tdata san = new tdata();
san.fpath = filepath;
san.fsize = BytesToString(size);
name.Add(san);
}
foreach (tdata mak in name)
{
richTextBox1.SelectionFont = new Font("Tahoma", 9, FontStyle.Regular);
richTextBox1.AppendText("-> " + mak.fpath + "\r\n");
richTextBox1.SelectionFont = new Font("Tahoma", 9, FontStyle.Regular);
richTextBox1.AppendText("--> " + mak.fsize + "\r\n");
}
}
static String BytesToString(long byteCount)
{
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB
if (byteCount == 0)
return "0" + suf[0];
long bytes = Math.Abs(byteCount);
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes/Math.Pow(1024, place), 2);
return (Math.Sign(byteCount) * num).ToString() + " " +suf[place];
}
を使用して、このリストを生成?
コメント行は以前のテストのものです。
また、私はこの古い関数はyou.Iはあなたが彼らのフォルダでいくつかのファイルをwanted.Groupingのようなものを行っている助けることができる.maybe持っパス
string path (string data)
{
string[] p = data.Split('\\');
StringBuilder path = new StringBuilder();
for (int i=0; i < p.Length - 1; i++)
{
if (i > 0)
path.Append("\\");
path.Append(p[i]);
}
path.Append("\\");
return path.ToString();
}