Posts

Showing posts with the label streamreader

Read text file line by line using timer

Image
Read text file line by line using timer StreamReader sr = new StreamReader("C:/CR EZ Test/Log.txt"); //use with IF private void timer2_Tick(object sender, EventArgs e) { if ((line = sr.ReadLine()) != null) { //FileStream fs = File.Open("C:/CR EZ Test/Log.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //StreamReader sr = new StreamReader(fs); //use with While can't use with }else{ //while ((line = sr.ReadLine()) != null) //{ string dataLog = line.Split(new { ',' }, StringSplitOptions.None); mpa = (dataLog[1]); ml = (dataLog[2]); lph = (dataLog[3]); elapsedTime = float.Parse(dataLog[4]) / 1000; if (testStatus > 0) time = elapsedTime.ToString("0.0"); tb2.Value = int.Parse(dataLog[6]); if (chart1.Series[0].Points.Count > tb1.Value && tb1.Value > 0) { chart1.Series[0].Points.RemoveAt(0); ...