I would just like to apologise for mposting this, there are a lot of questions like this here but I can't find one that is specific to this.
I have a list and each item contains a DateTime, int and a string. I have successfully written all list items to a .txt file which is delimited by commas. For example 09/04/2015 22:12:00,10,Posting on Stackoverflow.
I need to loop through the file line by line, each line starting at index 0, through to index 2. At the moment I am able to call index 03, which returns the DateTime of the second list item in the text file. The file is written line by line, but I am struggling to read it back with the delimiters and line breaks.
I am sorry if I am not making much sense, I will appreciate any help, thank you.
string[] lines = File.ReadAllLines( filename );
foreach ( string line in lines )
{
string[] col = line.Split(',');
// process col[0], col[1], col[2]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With