I am trying to read items from CListBox and writing to a file using CFile.
Here is my code
int count = m_lstSelectedItems.GetCount();
CFile cfile_object;
cfile_object.Open( L"C:\\temp.txt", CFile::modeCreate|CFile::modeReadWrite);
for(int i=0; i<count; ++i)
{
int n;
LPTSTR s2 = new TCHAR[256];
memset(s2, 0, 256);
n = m_lstSelectedItems.GetTextLen(i);
m_lstSelectedItems.GetText(i, s2);
cfile_object.Write (s2, n);
cfile_object.Write("\n",2);
delete[] s2;
}
cfile_object.Close();
But I am getting this data
F:\Programs\Test\SelectDialo੧䘀㨀尀倀爀漀最爀愀洀猀尀吀攀猀琀尀匀攀氀攀挀琀䐀椀愀氀漀最开
Any suggestions to get correct data.
Thanks