Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

CreateDir

Create a new directory.

Declaration

Source position: diskh.inc line 22

function CreateDir(

  const NewDir: RawByteString

):Boolean;

function CreateDir(

  const NewDir: UnicodeString

):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

RemoveDir

  

Remove a directory from the file system.

Example

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.

Documentation generated on: Nov 23 2024