一个创建多层目录的函数

来源:互联网 发布:哪个地图数据最详细 编辑:程序博客网 时间:2024/06/02 15:59

BOOL MakeSureDirectoryPathExists( const char* lpszDirPath )   //lpszDirPath 为要创建的目录,如 "c:/dir1/dir2"
{
 string strDirPath = lpszDirPath;
 int nPos = 0;
 while( ( nPos = strDirPath.find( "//", nPos + 1 ) ) != -1 )
 {
  CreateDirectory( strDirPath.substr( 0, nPos ).c_str(), NULL );
 }
 return CreateDirectory( strDirPath.c_str(), NULL );
}

原创粉丝点击