VC确保存路径存在在,如果不存在则创建

void MakeSureDirExist(const char * pPath )
{
        if ( pPath == NULL)
               return;
       std:: string strPath( pPath);
       
        if (strPath.at(strPath.length() - 1) != '\\')
              strPath += '\\';

        int len = strPath.length();
        for( int i =0; i < len; ++i)
       {
               if(strPath[i]== '\\')
              {
                     :: CreateDirectory((strPath.substr(0, i)).c_str(), NULL );
              }
       }

}
本文为“技术点滴”的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注