Solved

Making multiple directories

Posted on 2004-10-01
3
164 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now