public void LoadItemsFromTextFiles() { string[] storeItemArray = File.ReadAllLines(@"..\..\StoreItems.txt"); foreach (string line in storeItemArray) { if (line[0] != '-') { string[] splitLine = line.Split('|'); StoreItem newItem = new StoreItem { Name = splitLine[0], Price = int.Parse(splitLine[1]), Type = splitLine[2], Image = splitLine[3] }; storeItems.Add(newItem); } } string[] discountArray = File.ReadAllLines(@"..\..\Discounts.txt"); foreach (string line in discountArray) { if (line[0] != '-') { string[] splitLine = line.Split('|'); discounts.Add(splitLine[0], int.Parse(splitLine[1])); } } string[] userArray = File.ReadAllLines(@"..\..\Users.txt"); foreach (string line in userArray) { if (line[0] != '-') { string[] splitLine = line.Split('|'); User newUser = new User { FirstName = splitLine[0], LastName = splitLine[1], UserName = splitLine[2], Password = splitLine[3] }; users.Add(newUser); } } if (File.Exists(@"C:\Windows\Temp\_shopping_cart.txt")) { string[] cartArray = File.ReadAllLines(@"C:\Windows\Temp\_shopping_cart.txt"); foreach (string line in cartArray) { try { StoreItem newItem = storeItems.First(item => item.Name == line); shoppingCart.Add(newItem); } catch { } } } }