mfc listbox 将里面的项目以及数据 存到txt的问题
我想将列表控件中的内容导出到TXT,请问高手,应该怎么做,我查了2个小时,都没找到适合的函数。...
我想将 列表控件中的内容导出到TXT,请问高手,应该怎么做,我查了2个小时,都没找到适合的函数。
展开
1个回答
展开全部
char* pszFileName="F:\\myfile.txt";
CStdioFile myFile;
CFileException fileException;
if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate),&fileException)
{
myFile.SeekToEnd();
myFile.WriteString(stime);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str1);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str2);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str3);
myFile.WriteString("\n");
myFile.Close();
MessageBox("文件写入成功","提示");
}
else
{
TRACE("Can't open file %s,error=%u\n",pszFileName,fileException.m_cause);
}
CStdioFile myFile;
CFileException fileException;
if(myFile.Open(pszFileName,CFile::typeText|CFile::modeCreate|CFile::modeReadWrite|CFile::modeNoTruncate),&fileException)
{
myFile.SeekToEnd();
myFile.WriteString(stime);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str1);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str2);
myFile.WriteString("\n");
myFile.SeekToEnd();
myFile.WriteString(str3);
myFile.WriteString("\n");
myFile.Close();
MessageBox("文件写入成功","提示");
}
else
{
TRACE("Can't open file %s,error=%u\n",pszFileName,fileException.m_cause);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询