I know how to read the whole file but how can I read only one line
EX: read line 3 only
I know how to read the whole file but how can I read only one line
EX: read line 3 only
By the% of the line, eg:
string[] allLines = File.ReadAllLines(filePath);
string linha1 = allLines[0];
string linha2 = allLines[1];
string linha3 = allLines[2];
string linha4 = allLines[3];
You will have to first select all rows and then through the index choose which one you want
var file = new StreamReader(caminhoArquivo);
string[] linhas = File.ReadAllLines(caminhoArquivo);
var textoDesejado = linhas[2];
file.Close();
Note that to select line 3, use index 2 and finally, do not forget to close the file.