保存CString字符串到文件

来源:互联网 发布:分时博弈指标源码 编辑:程序博客网 时间:2024/05/19 20:21
// 保存CString字符串到文件bool CChatDlg::SaveSecretTalk( CString strTalkContent ){
// 选择路径对话框CFileDialogdlgFile( FALSE, _T("txt"), NULL, OFN_NOCHANGEDIR | OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_CREATEPROMPT,_T("*.txt"), NULL );if( dlgFile.DoModal() == IDOK ){CStringstrFileName = _T("");CStringstrFilePath = _T("");strFilePath = dlgFile.GetPathName();CFile file( strFilePath, CFile::modeReadWrite|CFile::modeNoTruncate|CFile::modeCreate );file.Write("\xff\xfe", 2);// 设置Unicode编码文件头file.Write( _T("")+strTalkContent, strTalkContent.GetLength()*sizeof(TCHAR) );file.Close();return true; }}

0 0
原创粉丝点击