/// <summary> /// Load from a text file into the character list /// </summary> public List <Tax> Load() { List <Tax> results = new List <Tax>(); StreamReader sr = null; try { sr = new StreamReader(FILENAME); sr.ReadLine(); string row = ""; while ((row = sr.ReadLine()) != null) { Tax t = TaxMapper.FromString(row); results.Add(t); } } catch (FileNotFoundException fileNotFound) { Console.WriteLine(fileNotFound.FileName + " was not found"); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (sr != null) { sr.Close(); } } return(results); }
public TaxStateResponse LoadTax() { TaxStateResponse response = new TaxStateResponse(); List <FlooringTax> taxes = new List <FlooringTax>(); StreamReader sr = null; try { sr = new StreamReader("Taxes.txt"); sr.ReadLine(); string row = ""; while ((row = sr.ReadLine()) != null) { FlooringTax t = TaxMapper.ToTax(row); taxes.Add(t); } if (taxes.Count > 0) { response.Success = true; response.TaxRate = taxes; } } catch (FileNotFoundException fileNotFound) { response.Success = false; response.Message = "File was not found"; } finally { if (sr != null) { sr.Close(); } } return(response); }