Hi everyone sorry if it is not the place to ask this question but im new to this site and i am new to programming. I have recently been set an assignment for file searching and listing. Im in the first year of a course. What im trying to do is search in a folder what the user has requested. So far if i specify the folder in the code. it works for that folder. what i want to do is. the user inputs a folder of their choice and it searches for it. code is below:

else if (UserSelection == 4)
{
Console.Write("Please type a specified path:");
string User = Console.ReadLine();
DirectoryInfo folderChange = new DirectoryInfo(User);
FileInfo[] filechange = folderChange.GetFiles(User);
for (int index = 0; index < filechange.LongLength; index++)
{
Console.WriteLine("{0}.{1} ({2} bytes)", FileListNumbering++, filechange[index].Name, filechange[index].Length);
}
Console.ReadLine();
}

This part I am trying to do the samebut let the user search his own extension input. I have tried string[] fileFiltering = Directory.GetFiles("C:\\Windows", "*.{0}", UserInput); but I keep getting errors


else if (UserSelection == 2)
{
Console.Write("What filetype would you like to search for?: ");
string UserInput = Console.ReadLine();

if (UserInput == "exe")
{
string[] fileFiltering = Directory.GetFiles("C:\\Windows", "*.exe");
for (int index = 0; index < fileFiltering.Length; index++)
{
Console.WriteLine("{0}", fileFiltering[index]);
}
Console.ReadLine();
}

ANY HELP WOULD BE GREATLY APPRECIATED.