If you simply want to give inputs to your program using text file, so you don't need to write them always again and again, then you can just use Console.ReadLine() in case of console app as usual and launch the app using program.exe < inputs.txt.
If you want to do something more complex, like text analysys etc. Then StreamReader might be what you're looking for:
https://docs.microsoft.com/en-us/dotnet … work-4.7.2
A brief example:
using System;
using System.IO;
//...
using (StreamReader sr = new StreamReader(@"PathtoYourFile")) {
string fileContent;
fileContent=sr.readToEnd();
//Do your analysis here
}
//Other code
Or because StreamReader is a stream, you can do also something like this:
using System;
using System.IO;
//...
using (StreamReader sr = new StreamReader(@"PathToYourFile")) {
string currentLine;
while ((currentLine = sr.ReadLine()) != null)
{
//Do your line processing here
}
}
//Other code
Best regards
Rastislav