if (!PathIsDirectory(m_strFolderPath) )
{
CString strMsg
strMsg.Format ("指定路径\"%s\"不存在,是否创建?", m_strFolderPath)
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
{
if (!CreateDirectory(m_strFolderPath, NULL))//here
{
strMsg.Format ("创建路径\"%s\"失败!是否继续?", m_strFolderPath)
if (AfxMessageBox(strMsg, MB_YESNO) == IDYES)
return
}
}
}
其实就是一个函数:CreateDirectory
void C文件读写Dlg::OnWriteButton(){
char* pszFileName="F:\\myfile.txt"
CStdioFile myFile
CFileException fileException
if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate),&fileException)
{
CString strOrder
strOrder.Format("%d,%.3f\t",66,88.88)
myFile.WriteString(strOrder)
myFile.Close() }
else
{
TRACE("Can't open file %s,error=%u\n",pszFileName,fileException.m_cause)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)