Name

MkDir Procedure

Syntax

procedure MkDir(const Directory: string)

Description

Call MkDir to create a directory. If the directory cannot be created, Delphi reports an I/O error using the Windows error code, such as Error_Already_Exists if the directory already exists.

You can include or omit a trailing backslash character in the directory name.

MkDir is not a real procedure.

Example

// Create a directory, but only if it does not already exist.
procedure MakeDirectory(const Directory: string);
var
  Search: TSearchRec;
begin
  if FindFirst(Directory, faDirectory, Search) = 0 then
    FindClose(Search)
  else
    MkDir(Directory);
end;

See Also

ChDir Procedure, GetDir Procedure, IOResult Function, RmDir Procedure

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.