int MyCreateDirectory(char * str)
{
char dirPath[MAX_PATH];
char *lpszTmp;
//WIN32_FIND_DATA FindData;
//HANDLE hFind;
int i=0;
sprintf(dirPath,”%s”,str);
for(i=strlen(dirPath);i > 2;i–)
{
if(dirPath[i-1] != ‘\\’)
{
dirPath[i] = ‘\0′;
break;
}
}
//MessageBox(NULL,dirPath,”DD”,MB_OK);
for(i=strlen(dirPath);i > 2;i–)
{
if(dirPath[i-1] == ‘\\’)
{
dirPath[i-1] = ‘\0′;
break;
}
}
//MessageBox(NULL, dirPath,”dd”,MB_OK);
//MessageBox(NULL,dirPath,”DD”,MB_OK);
//hFind = FindFirstFile(dirPath,&FindData);
if(GetFileAttributes(dirPath) == 0xffffffff)
{
//遍历上级目录
if(strlen(dirPath) < 3) return 0;
MyCreateDirectory(dirPath);
}
CreateDirectory(str,NULL);
return 1;
}
>> 本文固定链接: http://www.vcgood.com/archives/1418