const int COL_NUM = 3;//表的列数
CFile file;
file.Open("D:\\test.txt",CFile::modeCreate|CFile::modeReadWrite);
//得到表头文字
LVCOLUMNA column;
char szCol[50];
column.pszText=szCol;
column.cchTextMax=50;
column.mask=LVCF_TEXT;
for(int i=0;i<COL_NUM;i++)
{
m_list.GetColumn(i,&column);
file.Write(szCol,strlen(szCol));
file.Write("\t",1);
}
file.Write("\r\n",2);
//得到每一行数据
for(int i=0;i<m_list.GetItemCount();i++)
{
for(int j=0;j<COL_NUM;j++)
{
CString text = m_list.GetItemText(i,j);
text+="\t";
file.Write(text,text.GetLength());
}
file.Write("\r\n",2);
}
file.Close();