Actually I converted my VC .net project from Use Multi-Byte Character Set to Use Unicode Character Set (i.e. Unicode support). Then lot of build errors fixed.



Before in my project, Iím reading the ANSI text file as below



CStdioFile l_oStdioFile;

CString l_strValue = _T("");

TCHAR l_chBuff[1024*10];

CFileException l_oFileEx;

CString m_strFileName = _T("C:\\Documents and Settings\\PHari\\Desktop\\ASAS.txt");

BOOL l_bResult = false;

try

{

l_bResult = l_oStdioFile.Open(m_strFileName,CFile::modeRead,&l_oFileEx);

int count = l_oStdioFile.GetLength();

if(!l_bResult)

return;

UINT l_nBytesRead = l_oStdioFile.Read(l_chBuff,1024*10);

l_oStdioFile.Close();

int l_nIndex = 0;

for(int l_nCount = 0; l_nCount < (int)l_nBytesRead; l_nCount++)

{

l_strValue += l_chBuff[l_nCount];

}

}

catch(CFileException oFileEx)

{

}



Once I changed my project to Unicode support. With the above code, Iím trying to read the Unicode text file, it is working fine.

But if I try to read the ANSI text file, it is not reading properly. This problem is coming Once I built my project with Unicode support.



Is it possible to read text file of type ANSI and unicode using CStdioFile as shown above? Or where Iím doing wrong?



My requirement is I need to read the text file of type ANSI and Unicode with above code.



Any help is appreciated.