forked from MicrosoftDocs/cpp-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarchive-class_23.cpp
More file actions
25 lines (20 loc) · 819 Bytes
/
carchive-class_23.cpp
File metadata and controls
25 lines (20 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
CFile myFile(_T("My__test__file.dat"),
CFile::modeCreate | CFile::modeReadWrite);
CString str1("String1"), str2("String2"), str;
// Create a storing archive.
CArchive arStore(&myFile, CArchive::store);
// Write str1 and str2 to the archive
arStore.WriteString(str1);
arStore.WriteString(_T("\n"));
arStore.WriteString(str2);
arStore.WriteString(_T("\n"));
// Close the storing archive
arStore.Close();
// Create a loading archive.
myFile.SeekToBegin();
CArchive arLoad(&myFile, CArchive::load);
// Verify the two strings are in the archive.
arLoad.ReadString(str);
ASSERT(str == str1);
arLoad.ReadString(str);
ASSERT(str == str2);