#include "Shlwapi.h"
...
...
...
CString m_strFolderPath=_T("E:\\path");
if(!PathIsDirectory(m_strFolderPath)){
CString strMsg;
strMsg.Format (_T("指定路径\"%s\"不存在,是否创建?"), m_strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
{
if (!CreateDirectory(m_strFolderPath, NULL ) )
{
strMsg.Format(_T("创建路径\"%s\"失败!是否继续?"), m_strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
return;
}
}
}
...
...
...
但是此处CreateDirectory有局限性,只能创建单层文件夹,如果需要创建多层,还需要自己写函数