用MFC如何创建文件夹?

2024-11-16 01:52:50
推荐回答(2个)
回答1:

CString strFolderPath="c:\\test"
// 判断路径是否存在
if (!PathIsDirectory(m_strFolderPath) )
{
CString strMsg;
strMsg.Format ("指定路径\"%s\"不存在,是否创建?", m_strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
{
if (!CreateDirectory(m_strFolderPath, NULL ) )
{
strMsg.Format ("创建路径\"%s\"失败!是否继续?", m_strFolderPath);
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
return;
}
}
}
-------------------------------------------------------
CreateDirectory(LPCTSTR lpPathName, //irectory name
LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD
)

回答2:

CString
strFolderPath="c:\\test"
//
判断路径是否存在
if
(!PathIsDirectory(m_strFolderPath)
)
{
CString
strMsg;
strMsg.Format
("指定路径\"%s\"不存在,是否创建?",
m_strFolderPath);
if
(AfxMessageBox(strMsg,
MB_YESNO)
==
IDYES)
{
if
(!CreateDirectory(m_strFolderPath,
NULL
)
)
{
strMsg.Format
("创建路径\"%s\"失败!是否继续?",
m_strFolderPath);
if
(AfxMessageBox(strMsg,
MB_YESNO)
==
IDYES)
return;
}
}
}
-------------------------------------------------------
CreateDirectory(LPCTSTR
lpPathName,
//irectory
name
LPSECURITY_ATTRIBUTES
lpSecurityAttributes
//
SD
)