Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a folder through BCB code? 2

Status
Not open for further replies.

jvff

Programmer
Apr 1, 2001
64
BR
Hello,
I want to create a folder through code. How can I do that? ThanQ, ;-)

JVFF (Janito Vaqueiro Ferreira Filho)
 
Syntax

#include <dir.h>
int mkdir(const char *path);
int _wmkdir(const wchar_t *path);

Description

Creates a directory.

mkdir is available on UNIX, though it then takes an additional parameter.

mkdir creates a new directory from the given path name path.

Return Value

mkdir returns the value 0 if the new directory was created.

A return value of -1 indicates an error, and the global variable errno is set to one of the following values:

EACCES Permission denied
ENOENT No such file or directory
hnd
hasso55@yahoo.com

 
BCB also has a whole slew of file management commands. Look at CreateDir.
Code:
void __fastcall TForm1::Button1Click(TObject *Sender)

{
  if (!DirectoryExists(&quot;c:\\temp&quot;))
  {
    if (!CreateDir(&quot;C:\\temp&quot;))
      throw Exception(&quot;Cannot create c:\\temp directory.&quot;);
  }
James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Another option is ForceDirectories. You can then put in an entier path, and all folders will be created on that path if they don't already exist.

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top