Read a specific line from .txt file.

The .txt contains the Name, Bank and Dmg of a specific character.
I don’t know how to get the 2nd line (Name) and place it as the name string.

void GrabInfoFromSheet()
    {
        Recog = "Player" + PlayerDataNr.ToString();
        StreamReader reader = new StreamReader(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments).ToString() + "/CombatBot/" + Recog);
        Name = reader.ReadLine();
    }

Anyone wanting to pull a random line from the string list, here’s the code I assembled from Aevin’s answer:
_
string path = “Assets/Resources/names.txt”;

		string[] lines = System.IO.File.ReadAllLines (path);

		c.name = lines[Random.Range(0,lines.Length)];

_
In my case I used it to pull a random name from a .txt which has over 100 names on different lines. Hope this might help someone looking for this kind of answer!

I would suggest using serialized data or JSon in your case, because it sounds like you would benefit from a data object.

But if you still want to use a text file just use:

//Edit
var strContent;
//Edit
using (var reader = new StreamReader(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments).ToString() + "/CombatBot/" + Recog))
{
    strContent = reader.ReadToEnd();
}

List<string> lines = new List<string>(strContent);
//print second line 
print(lines[1]);

I found what I was meant to do by following the link @jmgek gave me.

Recog = "Player" + PlayerDataNr + ".txt";
        string[] lines = System.IO.File.ReadAllLines(DefaultDataPath+ "/IGPlayers/" + Recog);

        Name = lines[0];