Description |
The GetDirectories method returns an array of DirectoryInfo objects for all the sub-directories of the current folder. 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 directory 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;
Folders : Array of DirectoryInfo;
i : Integer;
begin
// Create our directory info object
DirInfo := System.IO.DirectoryInfo.Create('C:\Base');
// And some sub-folders
DirInfo.CreateSubdirectory('First');
DirInfo.CreateSubdirectory('Second');
DirInfo.CreateSubdirectory('Third');
// List the folders under C:\Base
Folders := DirInfo.GetDirectories;
for i := 0 to Length(Folders)-1 do
Console.WriteLine(Folders[i].ToString);
// Now delete this nest of folders
DirInfo.Delete(true);
Console.Readline;
end.
| Show full unit code | First
Second
Third
| | Example of the second syntax | program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
DirInfo : System.IO.DirectoryInfo;
Folders : Array of DirectoryInfo;
i : Integer;
begin
// Create our directory info object
DirInfo := System.IO.DirectoryInfo.Create('C:\Base');
// And some sub-folders
DirInfo.CreateSubdirectory('First');
DirInfo.CreateSubdirectory('Second');
DirInfo.CreateSubdirectory('Third');
// List the folders under C:\Base containing 'r'
Folders := DirInfo.GetDirectories('*r*');
for i := 0 to Length(Folders)-1 do
Console.WriteLine(Folders[i].ToString);
// Now delete this nest of folders
DirInfo.Delete(true);
Console.Readline;
end.
| Show full unit code | First
Third
|
|
|
|