////////////////////////////////////////////////////////////////////////////////////////////////////////////SpecialSample2 //CStdioFile(テキストモードでのファイル入出力) ////////////////////////////////////////////////////////////////////////////////////////////////////////////SpecialSample2 void CShareDlg::OnButton85() { CString csBuf; //テキストモードのファイルクラス CStdioFile ifp; //c:\readme.txtをオープン 読込みモード if(ifp.Open("c:\\readme.txt", CFile::modeRead)==NULL){ TRACE("error\n"); return; } // //ループしてファイル内容を全て読込んて表示する // while(TRUE){ //テキストモードなので後ろの改行コードはカットしてくれる。 if(ifp.ReadString(csBuf)==NULL){ break; } TRACE("%s", csBuf); } //ファイルクローズ ifp.Close(); //テキストモードのファイルクラス CStdioFile ofp; //書き込みモード if(ofp.Open("c:\\writeme.txt", CFile::modeCreate | CFile::modeWrite)==NULL){ TRACE("error\n"); return; } //テキストモードなので\nは0x0d0x0aに変換されます ofp.WriteString("gora-\n"); ofp.WriteString("sigotosiro!!\n"); //ファイルクローズ ofp.Close(); }