写文件:

#include<fstream>

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
CStdioFile file;
file.Open(_T("parametertable.txt"), CFile::modeCreate|CFile::modeWrite);
file.WriteString(cstr+_T("\n"));//cstr---CString 类型
file.Close();

 

读文件:

CStdioFile file;
int isOPend;
isOPend = file.Open(_T("ParameterSetting.ini"),CFile::modeRead);
if (!isOPend)
 {AfxMessageBox(_T("文件不存在或加载错误!"));
   return;}
CString strLine;
while(file.ReadString(strLine)) //每行读入strLine
    {......}
file.Close();

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄