making a directory

G

Gurpreet Singh

hi everyone,
i want to create a folder on the harddisk using c program.
the folder is infact a nested folder like sec1\subsec22\subsec9
to be created in c:\ drive.
I tried the following statement
mkdir ( c:\\sec1\\subsec22\\subsec9);
but it does not work.

the 'system' command system("md sec1\\subsec22\\subsec9")
is also not working.

Please help whether there is some problem in syntax or some special
setting is to be done prior to using the 'system' command.

Is there any alternative by which i can create the folder.

Note that neither mkdir nor rmdir is working with such a path.
 
I

Ian Collins

Gurpreet said:
hi everyone,
i want to create a folder on the harddisk using c program.
the folder is infact a nested folder like sec1\subsec22\subsec9
to be created in c:\ drive.
I tried the following statement
mkdir ( c:\\sec1\\subsec22\\subsec9);
but it does not work.
While off topic, the answer is simple: create the path one level at a time.
 
Z

Zeppe

Gurpreet said:
hi everyone,
i want to create a folder on the harddisk using c program.
the folder is infact a nested folder like sec1\subsec22\subsec9
to be created in c:\ drive.
I tried the following statement
mkdir ( c:\\sec1\\subsec22\\subsec9);
but it does not work.

the 'system' command system("md sec1\\subsec22\\subsec9")
is also not working.

Please help whether there is some problem in syntax or some special
setting is to be done prior to using the 'system' command.

Is there any alternative by which i can create the folder.

Note that neither mkdir nor rmdir is working with such a path.

in addition to the Ian's suggestion to create them one at time, take a
look to boost::filesystem
(http://www.boost.org/libs/filesystem/doc/index.htm)

Regards,

Zeppe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,173
Latest member
CliftonBar

Latest Threads

Top