首页 > 其他 > 详细

vc递归创建文件夹

时间:2015-01-21 21:46:55      阅读:342      评论:0      收藏:0      [点我收藏+]
 1 void  CreateDir(const string& strPath)
 2 {
 3     if (PathFileExists(strPath.c_str()))
 4     {
 5         return;
 6     }
 7 
 8     size_t sPrePos = 0;
 9     string strTmp = "";
10     size_t sPos = strPath.find(\\);
11     if (sPos == string::npos)
12     {
13         return;
14     }
15 
16     strTmp = strPath.substr(0, sPos + 1);
17     if ( !PathFileExists( strTmp.c_str() ) )
18     {
19         return;
20     }
21 
22     sPrePos = sPos + 1;
23     sPos = strPath.find(\\, sPrePos);
24     while (sPos != string::npos)
25     {
26         strTmp = strPath.substr(0, sPos);
27         if (!PathFileExists(strTmp.c_str()))
28         {
29             CreateDirectory(strTmp.c_str(), NULL);
30         }
31 
32         sPrePos = sPos + 1;
33         sPos = strPath.find(\\, sPrePos);
34     }
35 
36     if (!PathFileExists(strPath.c_str()))
37     {
38         CreateDirectory(strPath.c_str(), NULL);
39     }
40 
41 }

 

vc递归创建文件夹

原文:http://www.cnblogs.com/liuxupiaoshi/p/4239882.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!