Solved

Making multiple directories

Posted on 2004-10-01
3
165 Views
Last Modified: 2010-04-04
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
Comment
Question by:ZaSz
3 Comments
 
LVL 17

Assisted Solution

by:mokule
mokule earned 150 total points
ID: 12202537
Hi,
ForceDirectories(NewDstPath);
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 150 total points
ID: 12202538

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
 
LVL 1

Author Comment

by:ZaSz
ID: 12202610
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question