Chinaunix首页 | 论坛 | 博客
  • 博客访问: 562228
  • 博文数量: 97
  • 博客积分: 5090
  • 博客等级: 大校
  • 技术积分: 969
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-01 14:56
文章分类

全部博文(97)

文章存档

2011年(1)

2009年(1)

2008年(14)

2007年(37)

2006年(44)

我的朋友

分类: WINDOWS

2008-04-18 11:53:10


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);
        }
    }
}

阅读(7630) | 评论(3) | 转发(1) |
给主人留下些什么吧!~~

chinaunix网友2009-06-23 20:50:08

access(strFilePath, 0) == 0是什么意思

luojiafeng19842008-04-21 10:59:33

对,这个是MFC做的,如果用sdk的话,你得用MSDN查一下 SH开头的函数,再看看具体的用法。

chinaunix网友2008-04-20 01:19:36

这个是用MFC 来做的吧? 我想找直接用API 的sdk的开发方法