Read from a predefined line in txt

2

I am doing a txt file to save some information from a root user (username, password, name, cpf, email) in order, and I would like to know how do I read just the line that I would like, cpf or email or user.

    
asked by anonymous 28.05.2018 / 20:17

1 answer

3

You can do this as follows

string cpf = File.ReadAllLines(@"caminho\arquivo.txt")[3];

in case the index of the line is passed (3 because the indicies start at 0)

Another alternative is to put all rows in a list of string and then get the desired element

List<string> linhas = File.ReadAllLines(@"caminho\arquivo.txt").ToList();

string cpf = linhas.ElementAt(3);
    
28.05.2018 / 20:22