1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
CString FileName(
"test.txt"
),str(
""
);
CStdioFile file;
// 创建文件“test.txt”,写入"1234567890"
file.Open(FileName, CFile::modeCreate|CFile::modeWrite);
file.WriteString(
"1234567890"
);
file.Close();
// 追写入“abc”
file.Open(FileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
file.WriteString(
"abc"
);
file.Close();
// 读出第一行字符串,并用消息框弹出
file.Open(FileName,CFile::modeRead);
file.ReadString(str);
file.Close();
MessageBox(str);
|