你知道MFC如何在文件尾追加数据吗?相信很多小伙伴们对于MFC在文件尾追加数据的方法都很有兴趣,那么下面我们就一起跟小编去看看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文件操作的相关技巧,希望对大家的学习有所帮助。新闻热点
疑难解答
图片精选