1 bool createPath( string &dst ) 2 { 3 //判断目录是否存在 4 if(_access(dst.c_str(),0)!=-1) 5 return true; 6 //创建目录,失败则创建上一级 7 if (!CreateDirectory( dst.c_str(),NULL)) 8 { 9 string path=dst.substr(0,dst.find_last_of('\\')); 10 createPath(path); 11 return CreateDirectory(dst.c_str(),NULL); 12 } 13 else 14 return true; 15 }
使用 CreateDirectory来创建文件夹
使用_access 判断目录存在状态
浙公网安备 33010602011771号