SmartPascal
ForceDirectories
Function
Create a new path of directories SysUtils unit
 function ForceDirectories ( const Path : string ) : Boolean;
Description
The ForceDirectories function creates one or more nested directories specified by the Path.
 
If the create succeeded, then True is returned, otherwise the error can be obtained using GetLastError.
Related commands
CreateDir Create a directory
GetCurrentDir Get the current directory (drive plus directory)
GetDir Get the default directory (drive plus path) for a specified drive
MkDir Make a directory
ChDir Change the working drive plus path for a specified drive
RmDir Remove a directory
RemoveDir Remove a directory
SelectDirectory Display a dialog to allow user selection of a directory
SetCurrentDir Change the current directory
 
Example code : Create a new path on the C drive
begin
  // Try to create a new nested directory in the current directory
  if CreateDir('C:\NonExistantDir\TestDir')
  then ShowMessage('New directory added OK')
  else ShowMessage('New directory add failed with error : '+
                   IntToStr(GetLastError));

  // Now force it to create this directory
  if ForceDirectories('C:\NonExistantDir\TestDir')
  then ShowMessage('New directory added OK')
  else ShowMessage('New directory add failed with error : '+
                   IntToStr(GetLastError));
end;
Show full unit code
   New directory add failed with error 3
   New directory added OK