Description |
The hierarchy of directories (folders) in the current path are checked against the actual machine file system. New directories are created so that the full path is now valid.
|
| Notes | Important : because Create is a reserved word in Delphi, you must prefix it by an & to tell Delphi to treat it as a method name.
|
|
Microsoft MSDN Links |
System.IO
System.IO.DirectoryInfo
|
|
|
Creating a nest of two new directories and then deleting them |
program Project1;
{$APPTYPE CONSOLE}
uses
System.IO;
var
DirInfo : System.IO.DirectoryInfo;
Path : String;
begin
Path := 'C:\Dir1\Dir2';
if System.IO.Directory.Exists(Path)
then Console.WriteLine('{0} exists', Path)
else Console.WriteLine('{0} does not exist', Path);
// Create a DirectoryInfo object for this nest of 2 folders
DirInfo := System.IO.DirectoryInfo.Create(Path);
// Create the nest of 2 new folders
DirInfo.&Create;
if System.IO.Directory.Exists(Path)
then Console.WriteLine('{0} exists', Path)
else Console.WriteLine('{0} does not exist', Path);
// Now delete this nest of folders
DirInfo.Delete;
Console.Readline;
end.
| Show full unit code | C:Dir1Dir2 does not exist
C:Dir1Dir2 exists
|
|
|
|