void CreateDirIterate(char *pathStr)
{
CString str = pathStr;
if( str[str.GetLength()-1] != '\\')
str += '\\';
int findFirst = 0,
findLast = -1;
CString folder;
char saveDir[MAX_PATH] = {0};
//GetCurrentDirectory(MAX_PATH, saveDir);
CString tmpDir;
tmpDir = str.Mid(0,3);
//SetCurrentDirectory(tmpDir);
while ((findFirst=str.Find('\\', findFirst)) != -1 && (findLast=str.Find('\\', findFirst+1)) != -1)
{
folder = str.Mid(findFirst+1, findLast-findFirst-1);
tmpDir += folder;
tmpDir += '\\';
findFirst += findLast;
findLast = findFirst - findLast;
findFirst = findFirst - findLast;
if (GetFileAttributes(tmpDir) != FILE_ATTRIBUTE_DIRECTORY)
{
CreateDirectory(tmpDir, NULL);
}
//SetCurrentDirectory(tmpDir);
}
//SetCurrentDirectory(saveDir);
//GetCurrentDirectory(MAX_PATH, saveDir);
}
int _tmain(int argc, _TCHAR* argv[])
{
CreateDirIterate("c:\\abfeaff\\be\\cb\\e");
return 0;
}
阅读(764) | 评论(0) | 转发(0) |