void CMailSearchDlg::ExportEmailList()
{
CString strExt = ".txt"; // 扩展名
CString strFilePath;
CString strFilter;
strFilter.Format("Text Files (*txt)|*txt|All Files (*.*)|*.*||");
CFileDialog dlg(FALSE, NULL, "", NULL, strFilter);
if (dlg.DoModal() == IDOK)
{
strFilePath = dlg.GetPathName();
if (strFilePath.Find(strExt) == -1)
{
strFilePath += strExt;
}
if ( access(strFilePath, 0) == 0 )
{
CString strQuery;
strQuery.Format("%s 已经存在,要替换它吗?", strFilePath);
if ( IDNO == ::MessageBox(m_hWnd, strQuery, "文件覆盖询问", MB_ICONQUESTION | MB_YESNO) )
{
return;
}
}
FILE *fp = fopen(strFilePath, "wt+");
if ( fp != NULL )
{
for ( int i = 0; i < m_wndEmailList.GetItemCount(); i++ )
{
CString strMail = m_wndEmailList.GetItemText(i, 1);
fputs(strMail, fp);
fputs("\r\n", fp);
}
fclose(fp);
}
}
}
阅读(7671) | 评论(3) | 转发(1) |