Board index » delphi » Making directory after directory after directory

Making directory after directory after directory

Quote
Christopher Fairbairn wrote in message <907044871.115...@Chaos.es.co.nz>...
>MkDir('C:\Jack\1998\June\');
>It will fail because I am trying to get it to create more than one
directory
>at once. Is there a way to make multiple directories at once?

Sure is, try:

ForceDirectories('C:\Jack\1998\June\');

It will create any necessary directories ...

-------
You can find me on #Delphi on Newnet (irc.newnet.net)

 

Re:Making directory after directory after directory


Hi,

I am wanting a program to be able to save some of its details to a file. The
problem is that the path to the file is not always in existence when the
files is required to be saved.

I am using code like

Memo1.Lines.Savetofile('C:\Jack\1998\June\Data.193');

The problem is that that directory structure may not exist when I call this
line and of course this will crash the application.

What I require is to produce a procedure that will input a filename and make
the directories in its path if they are required. Eg

Say that the directory Jack existed but the directory 1998 and June didn't.
If I execute MkDir with something like the following:

MkDir('C:\Jack\1998\June\');

It will fail because I am trying to get it to create more than one directory
at once. Is there a way to make multiple directories at once?

Thanks,
Christopher Fairbairn

Re:Making directory after directory after directory


In article <907044871.115...@Chaos.es.co.nz>, lgc...@es.co.nz (Christopher

Quote
Fairbairn) wrote:
> What I require is to produce a procedure that will input a filename and make
> the directories in its path if they are required.

Delphi provides such a procedure, ForceDirectories (path).  You should find
it in the help, although it's very poorly indexed.

Angus

Other Threads