功能说明:
需要在相对项目的目录下,使用系统时间作为文件夹名称,新建文件夹,代码如下:
...
SYSTEMTIME st;//定义本地时间变量,该变量为结构体
GetLocalTime(&st);//获取本地时间函数,参数为时间变量指针
string foldName = to_string(st.wYear) + '_'+ to_string(st.wMonth) + '_' + to_string(st.wDay) + '_' + to_string(st.wHour) + '_' + to_string(st.wMinute) + '_' + to_string(st.wSecond);
std::string folderPath2 = ".\\OutData\\" + foldName;
mkdir(folderPath2.c_str());//可以实现相同的功能,新家文件夹,优点是,可以避免字符类型的差异带来的错误(原则上最好使用Unicode字符集),此时需要加头文件:#include <direct.h>
//CreateDirectory(folderPath2.c_str(), NULL);
...