这样写有什么问题呢?
////////////////////
void CxingchengDlg::OnBnClickedButton2()
{
.....................
sfile = dlg.GetPathName();
...................
}
////////////////
void CxingchengDlg::OnBnClickedButton3()
{
..................
dfile = dlg.GetPathName();
............
}
................................
//读出文件中的内容
CString s;
CString str;
CFile f;
CStdioFile File;
//f.Open(sfile,CFile::modeRead); //int length=f.GetLength(); while(File.ReadString(s))//循环读取文件,直到文件结束
    { 
  s+="\n";
    }
f.Close();
//////////////////////////////////
 CFile file ;
file.Open(dfile,CFile::modeWrite|CFile::modeCreate|CFile::modeNoTruncate);
    file.SeekToEnd();
    file.Write((LPCTSTR)s,s.GetLength()+1);
    file.Close(); MFC  cstring

解决方案 »

  1.   

    >>while(File.ReadString(s))//循环读取文件,直到文件结束
         { 
       s+="\n";
         }====
    你这样写很吃内存的吧,如果你的文件很大的话,最好一边读一边写入。
      

  2.   

    http://bbs.csdn.net/topics/390476867
      

  3.   

    你可以copyfile 这个更简单使用。。
      

  4.   

    while(File.ReadString(s))//循环读取文件,直到文件结束
         { 
    //用fput函数直接写到另一个文件中就可以了吧(个人建议)
       s+="\n";
         }
     f.Close();
      

  5.   

    在写入另外一个txt之前,断点调试下,看看你的CString s里面有没有东西?全不全??然后再进一步检查下写入操作。
      

  6.   

    单独再定义个CSstring.     ReadString.   只读一行
      

  7.   

    只是拷贝文件,干嘛要读入?使用copyfile不就可以了?BOOL CopyFile(
      LPCTSTR lpExistingFileName,
                              // pointer to name of an existing file
      LPCTSTR lpNewFileName,  // pointer to filename to copy to
      BOOL bFailIfExists      // flag for operation if file exists
    );
      

  8.   

      s+="\n";
    你以为S是奥特曼?