public Log(string title, string fileName) { InitializeComponent(); this.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); this.Text = title; var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); var sr = new StreamReader(fs); LogReader = new StreamReader(sr.BaseStream); txtLog.LoadFile(LogReader.BaseStream, RichTextBoxStreamType.PlainText); txtLog.SelectionStart = txtLog.Text.Length; txtLog.ScrollToCaret(); var monitor = new LogFileMonitor(fileName, "\n"); monitor.OnLine += (s, e) => { if (this.IsDisposed) { return; } txtLog.AppendText(e.Line); }; monitor.Start(); }
public frmMain() { InitializeComponent(); hideSubMenu(); var monitor = new LogFileMonitor(rustlocation, "\r\n"); monitor.OnLine += (s, e) => { pullfile(); }; monitor.Start(); }