为什么不能两次读取配置文件?
我做了一个类似文件打开的对话框,在创建这个对话框之前,读一个配置文件,第一次打开某个文件,读配置文件没问题,可是当我再一次打开某个文件后,读取配置文件的值都为0了,代码如下:
CString str;
GetPrivateProfileString("CARDSET","TempRate",NULL,str.GetBuffer(MAX_PATH),MAX_PATH,".//config.ini");
tempRate =atoi(str);
str.ReleaseBuffer();
CFileDialog dlg(true, "*.txt", ".txt");
if (dlg.DoModal() == IDCANCEL)
{
return;
}
else
{
CString strSourceFile = dlg.GetPathName();
CFile mFile;
if (mFile.Open(strSourceFile,CFile::modeRead)==0)
{
MessageBox("打开历史数据文件失败!");
return;
}
}