How to overwrite the CString in the CFile
-
we are writting the CString data in to the file using CFile. first time we are able to write the data correctly but from second time data is not overwritten. even if we remove the file , the file is generatted with same data.If any one have Idea how this prob can solved please give me. (CFile::modeCreate | CFile::modeWrite)
-
we are writting the CString data in to the file using CFile. first time we are able to write the data correctly but from second time data is not overwritten. even if we remove the file , the file is generatted with same data.If any one have Idea how this prob can solved please give me. (CFile::modeCreate | CFile::modeWrite)
Can you please post the code? Being a computer, I find your faith in the technology to be amazing. But sorry, you dont have the right to issue this command!
-
we are writting the CString data in to the file using CFile. first time we are able to write the data correctly but from second time data is not overwritten. even if we remove the file , the file is generatted with same data.If any one have Idea how this prob can solved please give me. (CFile::modeCreate | CFile::modeWrite)
Read the data from the file and write to temproary file. Delete the file you were reading the data from. Rename the temproary file. Somethings seem HARD to do, until we know how to do them. ;-) _AnShUmAn_
-
we are writting the CString data in to the file using CFile. first time we are able to write the data correctly but from second time data is not overwritten. even if we remove the file , the file is generatted with same data.If any one have Idea how this prob can solved please give me. (CFile::modeCreate | CFile::modeWrite)
-
we are writting the CString data in to the file using CFile. first time we are able to write the data correctly but from second time data is not overwritten. even if we remove the file , the file is generatted with same data.If any one have Idea how this prob can solved please give me. (CFile::modeCreate | CFile::modeWrite)
Do you have error checking in place?
CString str; // or whatever you have CFile pFile; CFileException ex; // add exception handling char szError[255]; // add msg buffer if( !pFile.Open(szFile, CFile::modeCreate|CFile::modeWrite, &ex) ) { ex.GetErrorMessage(szError, 255, NULL); AfxMessageBox("File Error: " + szError, MB_OK|MB_ICONERROR); return; // or return FALSE; } if( !str.IsEmpty() ) // always check for data! { // Now write the data to file... pFile.Write((LPCTSTR)str, str.GetLength()); } // close pFile.Close();
HTH Mark