I am using C# and was wondering if there is a way to ask the user for a file name (in the console application) within the local documents. I don't really know how to structure this question when looking online but the code I have :
static void Main(string[] args)
{
string[] random1 = System.IO.File.ReadAllLines(@"//..Random1.txt");
foreach (string r1 in random1)
{
Console.WriteLine(r1);
}
But ideally I would want something like:
static void Main(string[] args)
{
Console.WriteLine("Enter the name of the file you would like to see")
// Following the input let's say " Potato.txt " is entered
string[] chosenFile1 = System.IO.File.ReadAllLines(@"//..Potato.txt");
foreach (string file in chosenFile1)
{
Console.WriteLine(file);
}
I am not entirely sure how to go about it as usually its dependant on the path of the files , but I thought this way would be more appropriate as different users from different devices can try this out. Hope this makes sense , all help appreciated.