Delphi for .NET FCL Examples Reference
| DirectoryInfo class | namespace |
| System.IO |
Declaration
type DirectoryInfo = class sealed(FileSystemInfo)
Description
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories.
Example
The following example demonstrates some of the main members of the DirectoryInfo class:
program System_IO_DirectoryInfo; {$APPTYPE CONSOLE} {$AUTOBOX ON} uses System.IO; type TestDirectoryInfo = class public class procedure Main; end; { TestDirectoryInfo } class procedure TestDirectoryInfo.Main; var di: DirectoryInfo; begin // Specify the directories you want to manipulate di := DirectoryInfo.Create('c:\MyDir'); try // Determine whether the directory exists if di.Exists then begin Console.WriteLine('That path exists already.'); Exit; end; // Try to create the directory di.&Create; Console.WriteLine('The directory was created successfully.'); // Delete the directory. di.Delete; Console.WriteLine('The directory was deleted successfully.'); except on e: Exception do Console.WriteLine('The process failed: {0}', e.ToString); end; end; //test program begin TestDirectoryInfo.Main; end. |
Example output
The directory was created successfully. The directory was deleted successfully.
Looking for Delphi for .NET demos / source code samples? Look no further, Delphi for .NET FCL Examples Reference is what you are searching for!

