海阔天空

海阔凭鱼跃 天高任鸟飞

 

递归创建文件夹


BOOL CreateMyDirectory(LPCTSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
    BOOL ret = FALSE;
    CString dir = lpPathName;
    int pos = 0;
    if (CreateDirectory(dir,lpSecurityAttributes))
        return TRUE;
    do
    {             
        pos = dir.ReverseFind('\\');
        dir = dir.Left(pos);
        //if(!PathFileExists(dir))
        if(!CheckFileExit(dir))
        { 
            if(CreateDirectory(dir,lpSecurityAttributes))
                CreateMyDirectory(lpPathName,lpSecurityAttributes);
        }
        else 
            ret = TRUE;        
    }
    while(!ret);
    
    return TRUE;
}

posted on 2010-05-26 13:59  liuym  阅读(273)  评论(0编辑  收藏  举报

导航