标签:har rect exist created div lib 好用 max rcp
方法挺多的,_access和_mkdir算是比较古典了,不过很好用。
#include <io.h> #include <direct.h> // 判断文件夹是否存在 bool IsDirExist(const char *pszDir) { if (pszDir == NULL) return false; return (_access(pszDir, 0) == 0); // io.h } // 创建目录 bool CreateDirectory(const char *dir) { if (NULL == dir) return false; char path[MAX_PATH]; int nPathLen = 0; strcpy(path, dir); if ( (nPathLen = strlen(path)) < 1 ) return false; for (int i = 0; i < nPathLen; ++i) { if (path[i] == ‘\\‘) { path[i] = ‘\0‘; _mkdir(path); // <direct.h> path[i] = ‘\\‘; } } return (0 == _mkdir(path) || EEXIST == errno); // EEXIST => errno.h errmo => stdlib.h }
标签:har rect exist created div lib 好用 max rcp
原文地址:https://www.cnblogs.com/2018shawn/p/12409171.html