Я пишу консольное приложение для отображения статистики папки на C: \ windows и показываю, что все файлы там есть, поэтому их можно упростить и связать тип файла с пользователем !. Это то, что я получил до сих пор:Типы файлов фильтрации C#
{
String extention = String.Empty;
// Prompt the user to enter extention type
Console.Write("Please enter extention type: ");
extention = Console.ReadLine();
// This gets the Folder location which in this case is C:\\windows
DirectoryInfo root = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Windows));
// This is basicly the bit that collects the data after the user has entered the extention type
FileInfo[] executables = root.GetFiles("*exe");
foreach (var exe in executables)
{
//This will show the word txt in the console window
Console.WriteLine(exe.Name);
}
}
}
}
{
String extention2 = String.Empty;
// Prompt the user to enter extention type
extention2 = Console.ReadLine();
// This gets the Folder location which in this case is C:\\windows
DirectoryInfo root2 = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Windows));
FileInfo[] text = root2.GetFiles("*.txt");
foreach (var txt in text)
{
//This will show the word txt in the console window
Console.WriteLine(txt.Name);
}
}
String extention4 = String.Empty;
// Prompt the user to enter extention type
extention4 = Console.ReadLine();
// This gets the Folder location which in this case is C:\\windows
DirectoryInfo root4 = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Windows));
FileInfo[] windows = root4.GetFiles("*.win");
foreach (var win in windows)
{
//This will show the word txt in the console window
Console.WriteLine(win.Name);
}
Посмотреть эту тему: http://stackoverflow.com/questions/20881645/how-to-display-the-statistics-about-all-the-files-in-a-folder-in-c- sharp/20881751 # 20881751 – Odrai