void mkdirWithcmd()
{
string defaultPath = "E:";
string folderPath = defaultPath + "\\testFolder";
string command;
command = "mkdir -p " + folderPath;
system(command.c_str());
}
调用说明:
判断文件夹是否已存在,不存在才创建:
string str = defaultPath + folderName;
const char *filename = str.c_str();
if (_access(filename, 0) == -1)
{
cout << "mkdir\n";
mkdirWithcmd(defaultPath, folderName);
}
else
{
cout << "文件件已存在\n";
}
需要添加头文件
#include <io.h>
多种方式可参考:
https://blog.csdn.net/sinat_41104353/article/details/83149441