StreamReader srStream = null;
if (File.Exists(stFilePath))
{
srStream = new StreamReader(stFilePath, System.Text.Encoding.UTF8);
listView1.Items.Clear();
//遍历txt文件里的所有行,并以ListView显示
while (!srStream.EndOfStream)
{
string _stLineValue = srStream.ReadLine();
ListViewItem _item = new ListViewItem();
_item.SubItems[0].Text = _stLineValue.Substring(0, _stLineValue.IndexOf("<----->"));
_stLineValue = _stLineValue.Substring(_stLineValue.IndexOf("<----->"));
_stLineValue = _stLineValue.Substring(7, (_stLineValue.Length - 7));
_item.SubItems.Add(_stLineValue.Substring(0, _stLineValue.IndexOf("<----->")));
_stLineValue = _stLineValue.Substring(_stLineValue.IndexOf("<----->"));
_stLineValue = _stLineValue.Substring(7, (_stLineValue.Length - 7));
_item.SubItems.Add(_stLineValue.Substring(0, _stLineValue.IndexOf("<----->")));
_stLineValue = _stLineValue.Substring(_stLineValue.IndexOf("<----->"));
_stLineValue = _stLineValue.Substring(7, (_stLineValue.Length - 7));
_item.SubItems.Add(_stLineValue.Substring(0, _stLineValue.IndexOf("<----->")));
if (_item.SubItems[3].Text.Equals("失败"))
{
_item.BackColor = Color.Red;
}
else
{
_item.BackColor = Color.Green;
}
listView1.Items.Add(_item);
}