delphirecursionmkdir

How can I Create folders recursively in Delphi?


Need some help in creating function which can create folders recursively with giving path:

C:\TestFolder\Another\AndAnother

Delphi function MkDir returning IOerror = 3.

MkDir('C:\TestFolder\Another\AndAnother');

Solution

  • Use

    ForceDirectories('C:\TestFolder\Another\AndAnother');
    

    (This is a standard RTL function, found in SysUtils.pas. Hence you do not need to create your own function, even though that wouldn't have been difficult.)