Create a folder with nested folders.

 

Syntax

function CreateFolder(const sFolderName: string): integer;

 

Parameters and return values

Parameter

Type

Value

sFolderName

string

full name of a folder you create; you can specify several nested folders;

 

Function result

Result

Value

0

all OK, folder was created successfully;

1

all OK, such folder already exist;

-1

folder name can't be empty;

-2

folder creating failure. Check the name, rights, and technical ability for creating folder in a specified path.

 

Example

const
  FOLDER_NAME = 'c:\temp\logs\today reports\';
var
  iResult: integer;
  s: string;
begin
  iResult := CreateFolder(FOLDER_NAME);
  
    case iResult of
      0: s := 'all ok, folder created';
      1: s := 'all ok, folder already exists';
     -1: s := 'folder name cannot be empty';
     -2: s := 'error folder creating';
    end;
    
  mLogScript(s, '');  
end.

Script work result

[17:59:32] (Log "CreateFolder"): all ok, folder created

[17:59:32] (Run "CreateFolder"): Script operation time: 3 ms

[17:59:32] (Run "CreateFolder"): Script done successfully.

[17:59:35] (Log "CreateFolder"): all ok, folder already exists

[17:59:35] (Run "CreateFolder"): Script operation time: 3 ms

[17:59:35] (Run "CreateFolder"): Script done successfully.
 

See also

FileExists

mLogScript