void CLogfile_analysisDlg::OnReadfile()
{
m_Grid.DeleteAllItems();
CString strText = "";
CString szLine = "";
CString strText1="Errors are captured";
CStdioFile file; //CStdioFile逐行读取类
int count=0;
file.Open("day1.log",CFile::modeRead);//
while( file.ReadString( szLine ) )//
{
//char *p="Errors";
if(strstr(szLine,m_Keywords)) //to check whether Errors was included in "szLine" sentence.*******
{
count=count+1;
CString str;
str.Format("%d",count);
UpdateData(TRUE);
int count1=m_Grid.GetItemCount();
m_Grid.InsertItem(count1,"");
m_Grid.SetItemText(count1,0,str);
m_Grid.SetItemText(count1,1,szLine);
}
}
file.Close();//
//strText1=strText1+(char*)count;
CString str;
str.Format("%d",count);
strText1="total "+str+" "+strText1;
SetDlgItemText(IDC_Editcount,str);
//MessageBox(strText1);
}
VC6.0逐行读取记录文件文本文件CStdioFile
关注
打赏