DirectoryExists (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following example creates a directory, C:\temp, if it does not already exist.

Code

uses
  FileCtrl;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if not SysUtils.DirectoryExists('C:\temp') then
    if not CreateDir('C:\temp') then
      raise Exception.Create('Cannot create C:\temp');

  if not CreateDir('C:\temp') then
    raise Exception.Create('Cannot create C:\temp again!');
end;

Uses