Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When the path of Korean, open file error:

C#
int mMinSize;
string mstrReturn;
char *mcharReturn;
const wchar_t *mchar;
ifstream mstream;
wchar_t *mwchar = _T("D:\\kankan\\한국어\\MultiLanguage.dat");
mMinSize = WideCharToMultiByte(CP_ACP, NULL, mwchar, -1, NULL, 0, NULL, FALSE);
mcharReturn = new char[mMinSize + 1];
WideCharToMultiByte(CP_ACP, NULL, mwchar, -1, mcharReturn, mMinSize * 2, NULL, FALSE);
mstream.open(mcharReturn, ios::binary);
if (!mstream)
{
    //error  mcharReturn = "D:\\kankan\\???\\MultiLanguage.dat"
    return 0;
}
Posted

1 solution

The MS file stream classes support wchar file names since Visual Studio 2005. Just pass the wide char file name when using these.

With older VS versions use a different file access method that supports wide char file names (e.g. the Windows API with CreateFileW or the C library with _wfopen).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900