手机
当前位置:查字典教程网 >编程开发 >C语言 >MFC实现在文件尾追加数据的方法
MFC实现在文件尾追加数据的方法
摘要:本文实例讲述了MFC实现在文件尾追加数据的方法。分享给大家供大家参考。具体如下:BOOLCDelDlg::WritetoFile(CStri...

本文实例讲述了MFC实现在文件尾追加数据的方法。分享给大家供大家参考。具体如下:

BOOL CDelDlg::WritetoFile(CString sValue) { CString sFile = GetExePath() + "1.log"; CStdioFile file; if(file.Open(sFile, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)) { file.SeekToEnd(); // 移动文件指针到末尾 file.WriteString(sValue); file.Close(); } return FALSE; }

其中,GetExePath()代码如下:

// 返回可执行文件所在的目录(不包含最后的'') CString GetExePath() { char sFileName[256] = {0}; CString sPath = _T(""); GetModuleFileName(AfxGetInstanceHandle(), sFileName, 255); sPath.Format("%s", sFileName); int pos = sPath.ReverseFind(''); if(pos != -1) sPath = sPath.Left(pos); else sPath = _T(""); return sPath; }

希望本文所述对大家的MFC程序设计有所帮助。

【MFC实现在文件尾追加数据的方法】相关文章:

深入C++实现函数itoa()的分析

VC++开发中完美解决头文件相互包含问题的方法解析

c++实现strcat字符串连接库函数的方法详解

使用C++实现全排列算法的方法详解

MFC中exe图标修改的方法

解析如何用指针实现整型数据的加法

使用C语言实现CRC校验的方法

C++读写.mat文件的方法

自己实现strcpy函数的实现方法

去掉vs2010中ipch文件和.sdf文件的解决方法

精品推荐
分类导航