写入文件的例子 //创建文件 CStdioFile file; file.Open("ts.txt",CFile::modeCreate|CFile::modeWrite); //写入文件 CString str; str.Format("%s\r\n","hello!I am talkingmute!");(在末尾添加\r\n会导致写出来的文档修改后出现格式错乱,只能写\n) file.Seek(0,CFile::end); file.WriteString( str ); //关闭文件 file.Close(); 比如:读文件的例子 CString strText = “”; CString szLine = “”; //打开文件 CStdioFile file; file.Open("ts.txt",CFile::modeRead); //逐行读取字符串 while( file.ReadString( szLine ) ) { strText += szLine; } MessageBox(strText); //关闭文件 file.Close();