Description |
The GetFileSystemInfos method returns an array of FileSystemInfo objects for all the files in the current directory. Optionally, this list may be limited by the Filter string.
The array size is dynamically set by this method.
This filter string may contain valid file name characters, but may not have consecutive . characters. Use * wildcard to represent a sequence of 0 or more characters, and ? to represent a single character.
|
|
Microsoft MSDN Links |
System.IO
System.IO.DirectoryInfo
|
|
|
An example of the 1st syntax |
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
DirInfo : System.IO.DirectoryInfo;
Path : String;
Files : Array of FileSystemInfo;
i : Integer;
begin
// Get the current folder
Path := System.IO.Directory.GetCurrentDirectory;
// And then get its parent folder
Path := System.IO.Directory.GetParent(Path).Tostring;
// Create our directory info object for this parent folder
DirInfo := System.IO.DirectoryInfo.Create(Path);
// Get the files and folders in this folder
Console.WriteLine('Files in : ' + Path + ' :');
Console.WriteLine;
Files := DirInfo.GetFileSystemInfos;
// Display the files - just the file names that is
for i := 0 to Length(Files)-1 do
Console.WriteLine(Files[i].Name);
Console.Readline;
end.
| Show full unit code | Files and folders in : C:\Documents and Settings\Neil\My Documents :
Borland Studio Projects
Corel User Files
LizaJet Packages
My Albums
My Diagrams
My eBooks
My Library
My Music
My Pictures
My PSP8 Files
My Received Files
My Videos
New Folder
Nursing Agency Solutions
SimCity 4
000000.gif
Adobe.pdf
Backup
bb01_1024.jpg
BB021024.jpg
bb09_1024.jpg
C drive fragmentation before Diskeeper.txt
D drive fragmentation before Diskeeper.txt
Default.rdp
desktop.ini
Diary.csv
HospitalCodeMapping.csv
HospitalCodes.csv
Hospitals.rtf
Hospitals.txt
Invoice Test.RTF
Invoice Test.TXT
KeyGenerator Screenshot.PNG
Let to Morris-Party Wall.bmp
Menu page 1.ppp
Menu page 2.ppp
New Invoice Print.RTF
New.rtf
ProjectSpellingCorrector190204.cfg
ProjectSpellingCorrector190204.dpr
ProjectSpellingCorrector190204.exe
ProjectSpellingCorrector190204.res
RPT0001.HTM
RPT0002.HTM
RPT0003.HTM
Test.html
Test.pdf
Test.RTF
Thumbs.db
Web.html
Weekly.csv
| | An example of the 2nd syntax | program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
DirInfo : System.IO.DirectoryInfo;
Path : String;
Files : Array of FileSystemInfo;
i : Integer;
begin
// Get the current folder
Path := System.IO.Directory.GetCurrentDirectory;
// And then get its parent folder
Path := System.IO.Directory.GetParent(Path).Tostring;
// Create our directory info object for this parent folder
DirInfo := System.IO.DirectoryInfo.Create(Path);
// Get the files and folders in this folder startnig with 'M'
Console.WriteLine('M* Files in : ' + Path + ' :');
Console.WriteLine;
Files := DirInfo.GetFileSystemInfos('M*');
// Display the files - just the file names that is
for i := 0 to Length(Files)-1 do
Console.WriteLine(Files[i].Name);
Console.Readline;
end.
| Show full unit code | M* Files and folders in : C:\Documents and Settings\Neil\My Documents :
My Albums
My Diagrams
My eBooks
My Library
My Music
My Pictures
My PSP8 Files
My Received Files
My Videos
Menu page 1.ppp
Menu page 2.ppp
|
|
|
|