环境:Win10,VS2017
代码:
#include <stdlib.h>
#include <io.h>
#include <string>
//空格路径带双引号
std::string AddDoubleQuotations(std::string value)
{
return '\"' + value + '\"';
}
//创建文件夹,folderPath为输入参数,函数内部会加上双引号
void CreateFolder(std::string folderPath)
{
if (_access(folderPath.c_str(), 0))
{
std::string cmd = "md " + AddDoubleQuotations(folderPath);
system(cmd.c_str());
}
}
int main()
{
std::string folderPath = "C:\\Users\\think\\Desktop\\C B\\D E\\EE";
CreateFolder(folderPath);
return 0;
}