Sign in Join
FPDoc Onlineexperiment

CreateDir function

In unit sysutils

Create a new directory.

Declaration

pascal
function CreateDir(const NewDir: RawByteString): Boolean

Description

CreateDir creates a new directory with name NewDir. If the directory doesn't contain an absolute path, then the directory is created below the current working directory.

The function returns True if the directory was successfully created, False otherwise.

Errors

In case of an error, the function returns False.

See also

Example: ex26

pascal
Program Example26;

{ This program demonstrates the CreateDir and RemoveDir functions }
{ Run this program twice in the same directory }

Uses sysutils;

Begin
  If Not DirectoryExists('NewDir') then
    If Not CreateDir ('NewDir') Then
      Writeln ('Failed to create directory !')
    else
      Writeln ('Created "NewDir" directory')
  Else
    If Not RemoveDir ('NewDir') Then
      Writeln ('Failed to remove directory !')
    else
      Writeln ('Removed "NewDir" directory');
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.