文件写入自定义格式化的实现(详细见内容)
void CChecknumDlg::OnSaveAs()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(FALSE,
"jak",
NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT,
"file (*.jak)|*.jak|all file(*.*)|*.*|",
this);
if(IDOK == dlg.DoModal ())
{
CString strfilename = dlg.GetFileName();
CString strpathname = dlg.GetPathName();
CFile myFile;
CFileFind myFindfile;
if(myFindfile.FindFile (strfilename) == FALSE)
{
myFile.Open (strfilename,CFile::modeCreate|CFile::modeWrite);
myFile.SeekToBegin ();
nCount =m_listCtrl.GetItemCount();
for(int i = 0 ; i <3 ; i++)
{
for(int j = 0 ; j < nCount ; j++)
{
CString item=m_listCtrl.GetItemText(j,i);
item+="\r\n";
myFile.Write (item,item.GetLength ());
}
}
myFile.Close ();
文本保存后读写内容为:
Scribble.res
vc60.idb
Scribble.pch
vc60.pdb
StdAfx.obj
ChildFrm.obj
MainFrm.obj
Scribble.ilk
Scribble.exe
Scribble.pdb
0xEA
0x4A
0xD3
0x9A
0xC0
0xBA
0x0C
0x56
0xDC
0xCE
10-11-05 15:03:14
10-11-05 16:51:40
10-11-05 15:03:16
10-11-05 16:51:40
10-11-05 15:03:16
10-11-05 15:03:16
10-11-05 15:03:16
10-11-05 15:08:06
10-11-05 15:08:06
10-11-05 15:08:06
现在我希望读出内容为:
Scribble.res 0xEA 10-11-05 15:03:14
vc60.idb 0x4A 10-11-05 16:51:40
Scribble.pch 0xD3 10-11-05 15:03:16
vc60.pdb 0x9A 10-11-05 16:51:40
StdAfx.obj . .
ChildFrm.obj . .
MainFrm.obj . .
Scribble.ilk . .
Scribble.exe . .
Scribble.pdb . .
在语法上要怎么实现?