selecting a random name from a txt file using c#
made a program that reads a txt file and displays the text in the console, having trouble figuring out how to randomly display one of the names in the txt file though any help?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Banketeshvar NarayanPosted Nov 8, 2015, 5:19 AM
string[] fileList = Directory.GetFiles(@"D:\RandomFiles", "*.txt");
string fileToRead = fileList[r.Next(0, fileList.Length)];