Unicode CString and fopen problem
-
Dear Experts Previously I could open a file by using following code snippet in Visual C++ 6 : CString fileName = "c:\\1.bin"; fopen(fileName,"wb"); But now I switched to visual C++ 2005 and activate unicode character set, but above code does not work. Please give a code snippet that I can use to feed a CString as a array of TCHAR to fopen function. Thanks Mahdi
-
Dear Experts Previously I could open a file by using following code snippet in Visual C++ 6 : CString fileName = "c:\\1.bin"; fopen(fileName,"wb"); But now I switched to visual C++ 2005 and activate unicode character set, but above code does not work. Please give a code snippet that I can use to feed a CString as a array of TCHAR to fopen function. Thanks Mahdi
-
Dear Experts Previously I could open a file by using following code snippet in Visual C++ 6 : CString fileName = "c:\\1.bin"; fopen(fileName,"wb"); But now I switched to visual C++ 2005 and activate unicode character set, but above code does not work. Please give a code snippet that I can use to feed a CString as a array of TCHAR to fopen function. Thanks Mahdi
Use the
TCHAR
version offopen
. Then the code can be used with Unicode and MBCS builds:CString fileName = _T("c:\\1.bin");
_tfopen(fileName, _T("wb")); -
Hello, Since you set the property to Unicode Character Set, you can try like this.
CString fileName = L"c:\\\\1.bin"; CT2CA filen(fileName); fopen(filen,"wb");
Hope this helps. Regards, A. Gopinath.
Thanks , It works.
-
Use the
TCHAR
version offopen
. Then the code can be used with Unicode and MBCS builds:CString fileName = _T("c:\\1.bin");
_tfopen(fileName, _T("wb"));Thanks , it works perfect.