如何读取一个LOG文件 如何读取一个LOG文件,并在DataGrid中显示啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 LOG文件到底是什么格式的呀?请说清楚一下嘛。 就用stream这个对象去文以读取就好了。。 private bool f_readlog(string s_filepath) { try { string s_readline = ""; if (!(File.Exists(s_filepath))) { MessageBox.Show("日志文件不存在"); return false; } FileStream fs = new FileStream(s_filepath, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader sw = new StreamReader(fs); while (!sw.EndOfStream ) { s_readline=sw.ReadLine(); this.listBox1.Items.Add(s_readline); } sw.Close(); fs.Close(); } catch { MessageBox.Show("日志文件失败!"); return false; } return true; }这个是读LOG文件放在列表框里你想放在DataGrid的话,就把读取的内容写到一个DATATABLE里,再绑定到DataGrid C#链接多种数据库 一个继承自datagridview的WF控件的问题 100分求关于Rows.Find() 按鍵觸發生成XML文件的事件 求助!急急急 数据库链接工具少了 求解决方案! TreeView Web数据绑定的问题? 调用API问题,如何对应相应的数据类型? 求vs .net英文版下載 在for循环中,怎样做到每完成一次循环,就暂停,按下回车键后继续下一次循环 转贴一个在java论坛被骂的很惨的帖子 关于文件。 C#中有什么方法,得到父窗口中的子窗口吗?(很急,高手们,帮个忙)
{
try
{
string s_readline = "";
if (!(File.Exists(s_filepath)))
{
MessageBox.Show("日志文件不存在");
return false;
}
FileStream fs = new FileStream(s_filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sw = new StreamReader(fs);
while (!sw.EndOfStream )
{
s_readline=sw.ReadLine();
this.listBox1.Items.Add(s_readline);
}
sw.Close();
fs.Close();
}
catch
{
MessageBox.Show("日志文件失败!");
return false;
}
return true;
}
这个是读LOG文件放在列表框里
你想放在DataGrid的话,就把读取的内容写到一个DATATABLE里,再绑定到DataGrid