[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Making multiple directories

Hi, I would like to know what is the better method to use if I want to create multiple directories.
By multiple directories I mean I want to create something like "c:\a\b\c" if  "c:\a" does not exists.

The CreateDir() function is not working if the "a" dir is not existing. Anyone know a function able to do it?
0
ZaSz
Asked:
ZaSz
2 Solutions
 
mokuleCommented:
Hi,
ForceDirectories(NewDstPath);
0
 
Russell LibbySoftware Engineer, Advisory Commented:

ForceDirectories can be used to create the multi-level directory structure.

function ForceDirectories(Dir: string): Boolean;

Description

DOS and Windows only allow directories to be created one at a time. For example, to create the C:\APPS\SALES\LOCAL directory, the APPS and SALES directories must exist before the LOCAL directory can be created. Use ForceDirectories to create a directory and all parent directories that do not already exist.

ForceDirectories returns True if it successfully creates all necessary directories, False if it could not create a needed directory.

Note:      Do not call ForceDirectories with an empty string. Doing so causes ForceDirectories to raise an exception.

You will just need to include the FileCtrl unit in your uses clause.

Regards,
Russell
0
 
ZaSzAuthor Commented:
You posted at same time, one gave more details and the other was quicker.

Splitted the points to 150 each.
Thanks a lot!
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now