Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-11-2009
Member
 
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");
Reply With Quote
  #2  
Old 25-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #3  
Old 25-11-2009
Member
 
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);
    }

}
Reply With Quote
  #4  
Old 25-11-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:58 PM.