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”;
_
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]);