bool CreatedMultipleDirectory( char* direct)

bool CreatedMultipleDirectory( char* direct)
{
    string Directoryname = direct;
    if (  Directoryname[Directoryname.length() - 1] !=  '\\' )
    {
        //Directoryname +=
        Directoryname.append( 1, '\\');
    }
    std::vector<string> vpath;
    string strtemp;
    bool  bSuccess = false;
    for ( int i = 0; i < Directoryname.length(); i++ )
    {
        if ( Directoryname[i] != '\\')
        {
            strtemp.append( 1,Directoryname[i] );   
        }
        else
        {
            vpath.push_back( strtemp );
            strtemp.append( 1, '\\' );
        }
    }
    std::vector<string>:: const_iterator vIter;
    for ( vIter = vpath.begin();vIter != vpath.end(); vIter++ )
    {
        bSuccess = CreateDirectory( vIter->c_str(), NULL ) ? true :false;
    }
    return bSuccess;
}

Technorati Tags: MFC Windows ansi
posted @ 2011-05-24 11:20  麦峰强  阅读(314)  评论(0编辑  收藏  举报