Execute a line in a text file
- by apophis
Hi
I have a program that reads text files filled with code designed to be executed line by line by the program, like a script file. The problem is that I don't no how to do the line executing part. Here is my code, I thought using the \r would fool the console. But it just shows me a list of lines in the file.
if (tok[0] == "read" && length == 2)
{
try
{
StreamReader tr = new StreamReader(@"C:\Users\Public\"+tok[1]+".txt");
while (!tr.EndOfStream)
{
Console.WriteLine(tr.ReadLine());
}
}
catch
{
Console.WriteLine("No such text file.\n");
}
Prompt();
If I knew what to search for to fix my problem in Google, I would have. But I've got no idea.
Thanks