void write_to_file()
{
CFile test_file;
CString str_t;
str_t.Format(_T("file test."));
//创建txt文件,避免产生乱码
if(test_file.Open(_T(".\\test.txt"),CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite))
{
TCHAR setting = 0xfeff; //关键
test_file.Write(&setting,sizeof(TCHAR));
}
//写入内容
if(test_file.Open(_T(".\\test.txt"),CFile::modeWrite))
{
test_file.SeekToEnd();
test_file.Write(str_t,(str_t.GetLength())*2); //关键
}
test_file.Close();
}