I have written a CString Object into Text file by using :
f.Write (&FileName,FileName.GetLength());//FileName is CString Object
Now I want to Read CString object back How this could be done?I am using code :
LPTSTR p = CurrentLanguageName.GetBuffer(11);
void *g=(void *)p;
f.Read (g,CurrentLanguageFileLen);
CurrentLanguageName.ReleaseBuffer( );
//But this method don't work.
Regards,
you wrote it wrong -- what you wrote is the c++ class object, not the string contents. If the file is a normal text file where '\n' is line terminator then you need to tack on the '\n' to the end of the string then write only the string to the file.
Personally I hate the CFile class -- it is really crude and difficult to work with text files. A better solution is to use either standard c++ fstream if it is available with your compiler (and some compilers do not support it) or use CArchive in conjunction with CFile. CArchive will make the above code quite a bit easier and cleaner.
Last edited by Ancient Dragon; Oct 21st, 2007 at 6:57 am.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.