1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
CFile myFile("myfile", CFile::modeCreate | CFile::modeReadWrite);
CArchive arStore(&myFile, CArchive::store);
CString str;
arStore << listbox.GetCount(); // pour stocker le nb d'element pour la lecture...
for(int i=0;i<listbox.GetCount();i++)
{
listbox.GetText(i,str );
arStore.WriteString( str );
}
arStore.Close();
// lecture
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
listbox.ResetContent(); // vide la listbox
int nCount;
arLoad >> nCount;
for(int i=0;i<nCount;i++)
{
arLoad.ReadString(str);
listbox.AddString(str);
}
arLoad.Close(); |