文件夹不存在则创建

来源:互联网 发布:微信公众号电影源码 编辑:程序博客网 时间:2024/06/05 13:34

注意只能一级一级地操作,不能一次重建两层路径。


CString strFilePath = _T("C:\\a\\");//文件路径



if(!PathFileExists(strFilePath))//文件夹不存在则创建
{
CreateDirectory(strFilePath,NULL);

}


strFilePath = _T("C:\\a\\aa\\");
if(!PathFileExists(strFilePath))//文件夹不存在则创建
{
CreateDirectory(strFilePath,NULL);

}


以上是VS2010的结果


用VC6.0时,需要加头文件#include "shlwapi.h"

有可能出现无法识别的外部符号时,需要工程-》设置-》连接,添加库文件shlwapi.lib

0 0