Continuously read file with C#
More natural approach of using FileSystemWatcher: var wh = new AutoResetEvent(false); var fsw = new FileSystemWatcher(“.”); fsw.Filter = “file-to-read”; fsw.EnableRaisingEvents = true; fsw.Changed += (s,e) => wh.Set(); var fs = new FileStream(“file-to-read”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); using (var sr = new StreamReader(fs)) { var s = “”; while (true) { s = sr.ReadLine(); if (s != … Read more