Zi 字媒體
2017-07-25T20:27:27+00:00
純C++建立多層目錄函數
資料來源: http://codex.wiki/post/144728-632
void CMyCab::CheckTargetPath(string
targetPath)
{
//Log &log = Log::getLog(“main”,
“CheckTargetPath”);
int e_pos = targetPath.length();
int f_pos = targetPath.find(“\\”,0);
string subdir;
do
{
e_pos =
targetPath.find(“\\”,f_pos+2);
if(e_pos != -1)
{
subdir =
targetPath.substr(0,e_pos);
if(_mkdir(subdir.c_str())==0)
{
printf( “creat success
%s”,subdir.c_str());
}
else
{
printf(“creat fail
%s”,subdir.c_str());
}
}
f_pos = e_pos;
}while(f_pos!=-1);
}
寫了
5860316篇文章,獲得
23313次喜歡