CFileException ex;
if(!m_stdConfig.Open("..\\Config.ini",
CFile::modeCreate |
CFile::modeNoInherit |
CFile::modeWrite |
CFile::shareDenyWrite,&ex))
{
ex.ReportError();
ex.Delete();
return FALSE;
}m_stdConfig.WriteString(m_strBasePath+"\n");//+"\r\n"
m_stdConfig.WriteString(m_strDiffPath+"\n");
m_stdConfig.WriteString(m_strSaveDiffPath+"\n");
m_stdConfig.WriteString(m_strRNPathName+"\n");
以下这四个变量均为CString,前三个的值都是通过一个FolderDialog类取得的值(GetPathName()),最后一个变量m_strRNPathName是通过最普通的CFileDialog::GetPathName()取得。但就是这最后一个变量总是写不进文本文档里,用UltraEdit分析未见异常。如果这个变量没有写进文本里,其后再向文本里写任何字串都是0D 0A(\r\n),字串却不写入。哪位大哥能给解释一下原因。明天结贴。
m_strBasePath
m_strDiffPath
m_strSaveDiffPath
m_strRNPathName
if(!m_stdConfig.Open("..\\Config.ini",
CFile::modeCreate |
CFile::modeNoInherit |
CFile::modeWrite |
CFile::shareDenyWrite,&ex))
{
ex.ReportError();
ex.Delete();
return FALSE;
}m_stdConfig.WriteString(m_strBasePath+"\n");//+"\r\n"
m_stdConfig.WriteString(m_strDiffPath+"\n");
m_stdConfig.WriteString(m_strSaveDiffPath+"\n");
m_stdConfig.WriteString(m_strRNPathName+"\n");
以下这四个变量均为CString,前三个的值都是通过一个FolderDialog类取得的值(GetPathName()),最后一个变量m_strRNPathName是通过最普通的CFileDialog::GetPathName()取得。但就是这最后一个变量总是写不进文本文档里,用UltraEdit分析未见异常。如果这个变量没有写进文本里,其后再向文本里写任何字串都是0D 0A(\r\n),字串却不写入。哪位大哥能给解释一下原因。明天结贴。
m_strBasePath
m_strDiffPath
m_strSaveDiffPath
m_strRNPathName
void CConfigDlg::OnBtnBase()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_dlgFolder.DoModal()==IDOK)
{
m_strBasePath=m_dlgFolder.GetPathName();
UpdateData(FALSE);
}
}void CConfigDlg::OnBtnRn()
{
// TODO: Add your control notification handler code here
CFileDialog dlgFile(TRUE,NULL, "ReleaseNote.txt",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Release Note Files (*.txt)|*.txt||");
UpdateData(TRUE);
if(dlgFile.DoModal()==IDOK)
{
//m_strRNPathName=_T(dlgFile.GetPathName());
m_strRNPathName.Format(_T(dlgFile.GetPathName()));
UpdateData(FALSE);
}
}
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpString, // string to add
LPCTSTR lpFileName // initialization file
);
BOOL WritePrivateProfileSection(
LPCTSTR lpAppName, // section name
LPCTSTR lpString, // data
LPCTSTR lpFileName // file name
);
相关的函数还有很多,再MSDN中有详细的说明!
.Format()我试过了,没有用,_T什么的也白扯,我一点一点跟进MFC,都未发生任何问题,也就是说根本就没错,但就是生成的文本没有。你说奇不奇怪。算了,不那么好奇了,完成功能就行,谢谢两位捧场。结贴。