新建一对话框应用,在OnInitialDialog()里面添加下面代码
TCHAR* pFileName = _T("file.data");
CStdioFile f1;
if (!f1.Open(pFileName,CFile::modeCreate|CFile::modeWrite|CFile::typeText))
{
TRACE(_T("Unable to open file"));
}
f1.WriteString(_T("helloworld"));
f1.Flush();
f1.Close();