try to realize reading csv file with some structured data (this file used for my programm reminder - data in file structured with next way: date , name, time from, time till, description). Currently i want to read all data from file and put it in some string array, where each element - 1 line from file. what was done
write some code, that create stream for reading and opening file. But currently i can only read one line. or all file in one line. How to know, how many lines in file exist? or how to read all lines in file in array, where eaach element - one line from file.
Code
FileStream fs = new FileStream(FilePath, FileMode.Open,
FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs);
string lines = sr.ReadLine();
//temp veiw result
viewTextBox.Text = lines; //read only one first line in file
sr.Close();
or try to read all lines
string []line = File.ReadAllLines(FilePath); //read all lines in File
//temp check
for (int i=0; i<line.Length;i++){
viewTextBox.Text += line[i]; // in this case all data stored in one lines
}
i need this array with data, because next action - search some data in this array and show it in form.