我使用代碼從txt文件這樣寫行我如何完全讀取logserver文件?
2017-07-01 22:12:59 0 0 0 2 2 0 0 0 0 Mads Sarag hello iam Sarag
2017-07-01 22:13:05 0 0 3 2 4 0 0 0 0 Mads Sarag hello iam Sarag
但在數據gridview的最後一欄顯示一個字符串
代碼
class ReadPublicChat
{
public string date { get; set; }
public string time { get; set; }
public Int64 unk1 { get; set; }
public Int64 unk2 { get; set; }
public Int64 unk3 { get; set; }
public Int64 unk4 { get; set; }
public Int64 unk5 { get; set; }
public Int64 unk6 { get; set; }
public Int64 unk7 { get; set; }
public Int64 unk8 { get; set; }
public Int64 unk9 { get; set; }
public string AccName { get; set; }
public string CharName { get; set; }
public string Message { get; set; }
public static List<ReadPublicChat> LoadPublicChat(string path)
{
var PublicChat = new List<ReadPublicChat>();
foreach (var line in File.ReadAllLines(path))
{
string[] Columns = line.Split(new Char[] { ' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
if (line.Length > 0)
{
if (Convert.ToInt64(Columns[9]) == 0)
{
PublicChat.Add(new ReadPublicChat
{
date = Columns[0],
time = Columns[1],
unk1 = Convert.ToInt64(Columns[2]),
unk2 = Convert.ToInt64(Columns[3]),
unk3 = Convert.ToInt64(Columns[4]),
unk4 = Convert.ToInt64(Columns[5]),
unk5 = Convert.ToInt64(Columns[6]),
unk6 = Convert.ToInt64(Columns[7]),
unk7 = Convert.ToInt64(Columns[8]),
unk8 = Convert.ToInt64(Columns[9]),
unk9 = Convert.ToInt64(Columns[10]),
AccName = Columns[11],
CharName = Columns[12],
Message = Columns[13]
});
}
}
}
return PublicChat;
}
}
我需要有人編輯此代碼以讀取文件
請幫助完成該操作
感謝它的工作 – GameTech