VC6.0逐行讀取記錄檔案文字檔案CStdioFile
阿新 • • 發佈:2019-02-14
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); }