public TodoFileWatcher(TodoFile todoFile) { string path = Path.GetDirectoryName(Settings.Default.FileLocation); string filename = Path.GetFileName(Settings.Default.FileLocation); fileSystemWatcher = new FileSystemWatcher(path, filename); fileSystemWatcher.EnableRaisingEvents = true; fileSystemWatcher.Changed += delegate(object sender, FileSystemEventArgs e) { todoFile.Dirty = true; }; fileSystemWatcher.Deleted += delegate(object sender, FileSystemEventArgs e) { todoFile.Dirty = true; }; }
private void InitializeTodoText() { todoFile = new TodoFile(); todoText.Font = Settings.Default.Font; todoText.Text = todoFile.GetFileContents(); dirtyTextBox = false; todoText.Select(todoText.TextLength, 0); todoFileWatcher = new TodoFileWatcher(todoFile); fileTimer.Enabled = true; if (TodoTextInitialized != null) TodoTextInitialized(); }