I have 3 different notepad files, Jack.txt
Ken.txt
and Wizard.txt
how does this work in coding when I want to input in program for example, I input Ken
and the program should load Ken.txt
file, Jack
for Jack.txt
and so on.
The coding below is very basic and unfinished at the moment but no matter what I enter it loads the "Jack.txt" file. Would this work if I separate the coding into loop so when I enter "Wizard" it will loop till they find Wizard.txt file, if not an error message should appear.
//Prompt for input
System.Console.WriteLine("Please enter the name");
System.Console.Write("Name> ");
string name = System.Console.ReadLine();
// Fetch the file from input
string text = System.IO.File.ReadAllText(@"D:\Users\Jack\Documents\Test\Jack.txt");
string text1 = System.IO.File.ReadAllText(@"D:\Users\Jack\Documents\Test\Ken.txt");
string text2 = System.IO.File.ReadAllText(@"D:\Users\Jack\Documents\Test\Wizard.txt");
// Display the attributes to the console.
System.Console.WriteLine(" ");
System.Console.WriteLine("{0}", text);
}
}
}