设为首页 加入收藏

TOP

VC++创建指定路径的一系列文件夹
2014-11-23 19:30:43 】 浏览:2298
Tags:创建 指定 路径 系列 文件夹

方法很简单,就是简单的调用 PathFileExists()和CreateDirectory()函数,具体过程如下:

/***********生成指定路径的文件夹**********/
CString strPath = "G:\\Speech\\Text\\yuyin\\Store";//此处可随意定义,但格式必须与所示一致,会依次创建所有的,如果已经创建好了,则不创建
CString strWPath = strPath;
CString strTemp;
if(!PathFileExists(strPath))//文件夹不存在则创建
{

strPath.TrimLeft(strPath.Left(3));
int i = strPath.Find("\\");
if(i>0)
{
strTemp = strWPath.Left(3) + strPath.Left(i);
}
else
{
strTemp = strWPath;
}
strPath.TrimLeft(strPath.Left(i));
if(!PathFileExists(strTemp))
CreateDirectory(strTemp,NULL);

while(strPath.Find("\\") == 0)
{
strPath.TrimLeft(strPath.Left(1));
int j = strPath.Find("\\");
if(j > 0)
{
strTemp = strTemp + "\\" + strPath.Left(j);
strPath.TrimLeft(strPath.Left(j));
}
else
strTemp = strTemp + "\\" + strPath;
if(!PathFileExists(strTemp))
CreateDirectory(strTemp, NULL);
}
}


作者:pamchen
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇VC 调用外部程序接口 下一篇 VC++另类实现进程插入

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目