O'Reilly logo

Delphi for .NET Developer’s Guide by Xavier Pacheco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with the Directory System

To work with directories, you use the Directory or DirectoryInfo classes. The Directory class provides static methods and is convenient in that you do not have to create an instance of the class to use it. However, each call invokes a security check; therefore, it might be inefficient. In this case, you would use the DirectoryInfo class. These classes provide the methods to manipulate (create, delete, move, copy) directories and to enumerate through the directory hierarchies.

Creating and Deleting Directories

The following code shows how to create a directory using the DirectoryInfo class:

dirInfo := DirectoryInfo.Create('c:\ddgtemp');
if not dirInfo.Exists then
  dirInfo.&Create;

First, an instance of DirectoryInfo ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required