private void frmConfig_Load(object sender, EventArgs e) { try { txt_aion_path.Text = Config.get_game_path(); } catch (Exception exc) { } }
/// <summary> /// Create watcher for the specified file and monitor changes /// </summary> /// <param name="file_changed_func"></param> public FileWatcher(FileSystemEventHandler file_changed_func) { watcher = new FileSystemWatcher(); watcher.Path = Config.get_game_path(); //Always check the last write to the file watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Filter = "Chat.log"; //Callback watcher.Changed += new FileSystemEventHandler(file_changed_func); //Start watching watcher.EnableRaisingEvents = true; }
public LogReader() { string file = Config.get_game_path() + "\\Chat.log"; try { //Open the file FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); reader = new StreamReader(fs, System.Text.Encoding.Default); // set position to end reader.ReadToEnd(); // start the filewatcher watcher = new FileWatcher(file_changed); } catch (Exception e) { System.Windows.Forms.MessageBox.Show("The log file " + file + " can not be found! Please set your AION path", "Log file error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }