绝对路径就不举例了

相对路径:

#include <direct.h> //for _mkdir
#include <io.h>		//for _access


std::string dir = "./tmp";

void CreateDirectory()
{

    if (_access(m_dir.c_str(),0) == -1) // if the directory doesnot exist.
	{
		_mkdir(m_dir.c_str());    //create
	}

}

visual studio 2017

 

奇怪的是,直接运行没有问题。生成的./tmp在tmpProject/tmpProject目录下。

单步运行出错。

windows 创建目录

相关文章: