/*
shlwapi.h
shlwapi.lib
*/
void CAdsMngWnd::_checkAndcreateDirectory(const std::string DirPath)
{
std::string cs_tmp_dir;
int nfind = DirPath.find("//", 0);
while(nfind < DirPath.length())
{
if(nfind == -1)nfind = DirPath.length();
cs_tmp_dir = DirPath.substr(0, nfind);
if(!PathFileExists(cs_tmp_dir.c_str()))
::CreateDirectory(cs_tmp_dir.c_str(), NULL);
if(nfind < DirPath.length())
nfind = DirPath.find("//", ++nfind);
}
}
shlwapi.h
shlwapi.lib
*/
void CAdsMngWnd::_checkAndcreateDirectory(const std::string DirPath)
{
std::string cs_tmp_dir;
int nfind = DirPath.find("//", 0);
while(nfind < DirPath.length())
{
if(nfind == -1)nfind = DirPath.length();
cs_tmp_dir = DirPath.substr(0, nfind);
if(!PathFileExists(cs_tmp_dir.c_str()))
::CreateDirectory(cs_tmp_dir.c_str(), NULL);
if(nfind < DirPath.length())
nfind = DirPath.find("//", ++nfind);
}
}
博客给出了一段代码,用于检查并创建目录。代码包含头文件 shlwapi.h 和库文件 shlwapi.lib,定义了 _checkAndcreateDirectory 函数,通过查找路径中的分隔符,逐步检查并创建目录。

335

被折叠的 条评论
为什么被折叠?



