logo
CSharp_Prog_Guide

Создание списка каталогов

В следующем примере кода показано использование классов ввода/вывода для создания списка всех файлов с расширением ".exe" в каталоге.

Пример

-------

Robust Programming

In this example, the DirectoryInfo is the current directory, denoted by ("."), and the code lists all files in the current directory having a .exe extension, along with their file size, creation time, and name. Assuming that there were .exe files in the \Bin subdirectory of C:\MyDir, the output of this code might look like this:

953 7/20/2000 10:42 AM C:\MyDir\Bin\paramatt.exe

664 7/27/2000 3:11 PM C:\MyDir\Bin\tst.exe

403 8/8/2000 10:25 AM C:\MyDir\Bin\dirlist.exe

If you want a list of files in another directory, such as your C:\ root directory, pass the argument "C:\" into the executable generated by compiling this code, for example: "testApplication.exe C:\".