I need to read a text file into a ListView. I have already saved it to the file, but it doesn't seem that anyone has a good answer for reading the file back in. When the file reads in; all the data is in the first column and not in displayed under the appropriate headers.
Here is my text file data as it was saved to the file:
05 / 23 / 2017
10 : 44
13 : 44
3
$48.00
05 / 23 / 2017
09 : 15
15 : 15
6
$96.00
Here is the code I used:
private void ReadInTimeSheet()
{
foreach (string line in File.ReadAllLines(@"C:filepath\MyTimeSheet.txt"))
{
lvTimeSheet.Items.Add(new ListViewItem(line));
}
}
And here are the Results from the read in: Data displayed in ListView
In case you have problems opening the file; all the data is contained in the first column, and looks exactly as the view I have of the text in the file above.
What I need is the date displayed in column 1, start time in column 2, stop time in column 3, total hours worked in column 4, and how much pay the hours receive in column 5.
How can I achieve this? Thank you in advance.