MFC程序中如何创建多级目录
65. MFC程序中如何创建多级目录
BOOL mkdirEx(const char* lpPath)
{
CString pathname = lpPath;
if(pathname.Right(1) != "\")
pathname += "\" ;
int end = pathname.ReverseFind('\');
int pt = pathname.Find('\');
if (pathname[pt-1] == ':')
pt = pathname.Find('\', pt+1);
CString path;
while(pt != -1 && pt<=end)
{
path = pathname.Left(pt+1);
if(_access(path, 0) == -1)
_mkdir(path);
pt = pathname.Find('\', pt+1);
}
return true;
}
BOOL mkdirEx(const char* lpPath)
{
CString pathname = lpPath;
if(pathname.Right(1) != "\")
pathname += "\" ;
int end = pathname.ReverseFind('\');
int pt = pathname.Find('\');
if (pathname[pt-1] == ':')
pt = pathname.Find('\', pt+1);
CString path;
while(pt != -1 && pt<=end)
{
path = pathname.Left(pt+1);
if(_access(path, 0) == -1)
_mkdir(path);
pt = pathname.Find('\', pt+1);
}
return true;
}
上一篇:std::find,std::find_if使用小结
下一篇:MFC Telnet Application(mfc telnet 端口,代码实现、不调用telnet.exe)