Results 1 to 4 of 4

Thread: How to create a directory in c++

  1. #1
    Join Date
    Aug 2009
    Posts
    40

    How to create a directory in c++

    Can any one tell me how to create a directory in c++ and C language. I have tried this but not working :
    Code:
    system ("md directory");

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: How to create a directory in c++

    Code:
    #include <sys/stat.h>
     
    mkdir (const char *path, mode_t mode);
    There are mkdir and rmdir functions that should work in both environments (in Windows. The mkdir (make directory) command in the Unix, DOS, OS/2 and Microsoft Windows operating systems is used to make a new directory. They have an _ prefix that you can omit by a "define mkdir _mkdir" proprocessor statement.

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: How to create a directory in c++

    Try the following program to create directory in C++ :
    Code:
    #include<iostream.h>
    #include<sys/stat.h>
    #include<sys/types.h>
    using namespace std;
    
    main()
    {
    
        if(mkdir("path",0777)==-1)//creating a directory
        {
            cerr<<"Error :  "<<strerror(errno)<<endl;
            exit(1);
        }
    
    }

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: How to create a directory in c++

    System("mkdir -p /tmp/a/b/c") -p: will also create all directories leading up to the given directory that do not exist already. You can use or SHCreateDirectory or SHCreateDirectoryEx API ([To set security attributes on a new folder, use SHCreateDirectoryEx) to create Intermediate directories if they're not existing.

Similar Threads

  1. Create Active Directory integrated zone in DNS
    By Brruno in forum Networking & Security
    Replies: 3
    Last Post: 12-11-2010, 06:17 AM
  2. Should I create a virtual directory
    By Lashawn in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 09:28 PM
  3. How to create directory in ASP.net
    By Aspen in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 12:01 PM
  4. useradd: cannot create directory
    By MobiNuX in forum Operating Systems
    Replies: 2
    Last Post: 30-07-2009, 10:51 PM
  5. How to create an alias for a directory in Unix
    By Bull50 in forum Operating Systems
    Replies: 3
    Last Post: 02-05-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,920,849.32582 seconds with 16 queries