1
I know how to read the whole file but how can I read only one line
EX: read line 3 only
1
I know how to read the whole file but how can I read only one line
EX: read line 3 only
1
For index
line, example:
string[] allLines = File.ReadAllLines(filePath);
string linha1 = allLines[0];
string linha2 = allLines[1];
string linha3 = allLines[2];
string linha4 = allLines[3];
1
You first have to select all rows and then by 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 index 2 is used and finally, do not forget to close the file.
Browser other questions tagged c# string winforms
You are not signed in. Login or sign up in order to post.
I hadn’t thought of it that way thanks :)
– Miure Silva
@Miuresilva if it worked, don’t forget to mark as answered. Arrange.
– Barbetta