Will Rothwell
April 30th, 1999, 02:11 AM
Hi,
Can any one tell me how to achive a CStringArray object to a file. MFC help says CStringArray can be serialised. I tried and could not compile. I have the following code fragment:
CString strFileName = strEnvFullPath + "\\DATA.TMP";
CStringArray straUserList;
straUserList.SetSize(1);
int nListCount = 0;
CFile file(strFileName, CFile::modeCreate | CFile::modeWrite);
CArchive ar(&file, CArchive::store);
ar << straUserList; /*This is the ERROR line */
The error message I got is :
C:\DDK\src\ThSS\APP\SCR\SCREENER.CPP(1575) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class CArchive' (or there is no acceptable conversion)
On retrieving I put ar >> straUserList; , and I got:
C:\DDK\src\ThSS\APP\SCR\SCREENER.CPP(1978) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class CStringArray' (or there is no acceptable conversion)
I cannot use the supplied Serialize(..) function because I am stuffing objects to a file run time. However,
if I use a for loop doing something like this is OK:
for (int i = 0; i < nCount<i++) ar << straUserList[i];
Any idea please?
Will
Can any one tell me how to achive a CStringArray object to a file. MFC help says CStringArray can be serialised. I tried and could not compile. I have the following code fragment:
CString strFileName = strEnvFullPath + "\\DATA.TMP";
CStringArray straUserList;
straUserList.SetSize(1);
int nListCount = 0;
CFile file(strFileName, CFile::modeCreate | CFile::modeWrite);
CArchive ar(&file, CArchive::store);
ar << straUserList; /*This is the ERROR line */
The error message I got is :
C:\DDK\src\ThSS\APP\SCR\SCREENER.CPP(1575) : error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class CArchive' (or there is no acceptable conversion)
On retrieving I put ar >> straUserList; , and I got:
C:\DDK\src\ThSS\APP\SCR\SCREENER.CPP(1978) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class CStringArray' (or there is no acceptable conversion)
I cannot use the supplied Serialize(..) function because I am stuffing objects to a file run time. However,
if I use a for loop doing something like this is OK:
for (int i = 0; i < nCount<i++) ar << straUserList[i];
Any idea please?
Will