简体   繁体   中英

How to create directories in c++?

I am trying to create multiple directories in c++.

Here is what I am doing:

string folder="SYSTEM/app";
string patchFolder="D:/cpp/prototype/New_delta/patch/" + folder;
string mkdirCommand="mkdir " + patchFolder;
system(mkdirCommand.c_str());

But its giving: The syntax of command is incorrect.

path up to prototype exists and it has to create multiple folder(New_delta, patch etc.) if not exist already.

What is wrong with this and how to correct it? please.

Thank You.

You could use Boost library. Check out 3rd answer here

You could also use _mkdir or mkdir (but you will get warnings if you use mkdir)

#include <direct.h>
...
_mkdir(patchFolder.c_str());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM