Advertisement
njunwa1

logreader

Sep 13th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1.         private void timerLog_Tick(object sender, EventArgs e)
  2.         {
  3.             string logpath = "log.txt";
  4.             if (File.Exists(logpath))
  5.             {
  6.                 Stream stream = File.Open(logpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  7.                 StreamReader streamReader = new StreamReader(stream);
  8.                 string str = streamReader.ReadToEnd();
  9.  
  10.                 //rtblog is my RichTextBox
  11.                
  12.                 int startIndex = 0;
  13.                 int tempStartIndex = -1;
  14.  
  15.                 if ((tempStartIndex = str.LastIndexOf("Application engine version 2.0.2016 was initiated", startIndex)) > 0)
  16.                 {
  17.                     rtbLog.SelectedText = rtbLog.SelectedText + "Application engine Started\n";
  18.                 }
  19.                 else if ((tempStartIndex = str.LastIndexOf("Drivers not found", startIndex)) > 0)
  20.                 {
  21.                     rtbLog.SelectedText = rtbLog.SelectedText + "Drivers were not found navigate to settings Menu to install them\n";
  22.                 }
  23.  
  24.                 if (tempStartIndex != -1)
  25.                 {
  26.                     startIndex = tempStartIndex;
  27.                 }
  28.                 //rtbLog.Text = str;
  29.                 rtbLog.SelectionStart = rtbLog.Text.Length;
  30.                 rtbLog.ScrollToCaret();
  31.  
  32.  
  33.                 streamReader.Close();
  34.                 stream.Close();
  35.             }
  36.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement