/// <summary> /// Read the book title from file add to <see cref="BookDataCollection"/> /// collection. /// </summary> /// <param name="filePath">The path to the authors file. <see cref="String" /> .</param> public void ReadTitlesFromFileLoop(string filePath) { this._msgBox.NameOfMethod = MethodBase.GetCurrentMethod().Name; try { var coll = new BookDataCollection(); if (!this._validate.ValidateStringIsNotNull(filePath)) { return; } if (!this._validate.ValidateStringHasLength(filePath)) { return; } if (!this._validate.ValidateFileExists(filePath, true)) { return; } using (var sr = new StreamReader(filePath)) { string line; while ((line = sr.ReadLine()) != null) { coll.AddItem(line); } } } catch (OutOfMemoryException ex) { this._msgBox.Msg = "Not enough memory to continue. Try closing other windows."; Debug.WriteLine(ex.ToString()); this._msgBox.ShowErrorMessageBox(); } }