16,472
社区成员
发帖
与我相关
我的任务
分享
void C写入Dlg::OnBnClickedButton1()
{
CString str;
UpdateData(true);
UpdateData(true);
// TODO: 在此添加控件通知处理程序代码
}
CFile f;
f.Open(_T("D:\\a.txt"),CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate);
f.SeekToEnd();
CString a = _T("测试!\r\n");
char szBuffer[2] = {0xff,0xfe};
f.Write(szBuffer,2);
f.Write(a,a.GetLength()*2 );
f.Close();
CFile f;
f.Open(_T("d:\\a.txt"),CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate);
f.SeekToEnd();
CString a = _T("代购费!\r\n");
USES_CONVERSION;
const char *p = T2A(a);
f.Write(p,strlen(p) );
f.Close();
try
{
CFile f(_T("a.txt"), CFile::modeCreate|CFile::modeWrite|CFile::modeNoTruncate);
f.SeekToEnd();
CString a = _T("test sun!\r\n");
f.Write(a, a.GetLength() * sizeof(TCHAR));
f.Close();
}
catch(...)
{
}