I have added a Groceries.txt
file to my project which contains a list of items (eg. regular,bread,2.00,2) which translates to type, item, cost, quantity. My project contains the code of what needs to be actioned per each class. I have created an Invoice.txt
file. I would like my project file to read what is in the Groceries.txt
file run the program and then write to the Invoice.txt
file with today's date, each item listed in the Groceries.txt
file, list the number of items and the total cost. I have the following code added to my project but I have no idea how to connect the Groceries.txt
file to the code to make it execute they way I need it to. Any ideas of how I could do this:
int counter = 0;
string line;
System.IO.StreamReader file = new System.IO.StreamReader("Groceries.txt");
while ((line = file.ReadLine()) != null)
{
Console.WriteLine(line);
counter++;
}
file.Close();
Console.ReadLine();
string[] lines = { "FirstLine", "SecondLine", "ThirdLine" };
System.IO.File.WriteAllLines("Invoice.txt", lines);