Hi
I can't figure out what the problem is.
In my last post some users suggested me to use the CStdioFile for reading a whole line. That works FINE!I used the same Object to Write a file with the method WriteString. That works but the problem is i'd like to append Text in a file. However when i open the file with CFile::modeWrite and append data with WriteString the content of the file will be reseted to 0.
It is documented that when i use "CFile::modeWrite | CFile::modeCreate" the file will be reseted but only the CFile::modeWrite should not reset the file to 0?
What's my failure?
Thank you.
jaz
PHP Code:void CLogAppWndDlg::OnOK()
{
// TODO: Add extra validation here
CStdioFile fStream;
CString strBuffer;
UpdateData(TRUE);
strBuffer = m_tDatePicker.Format("%Y.%m.%d\t%a\t%H:%M:%S");
strBuffer = strBuffer + "\t" + m_strTxt + "\t" + m_strComment + "\n";
if( !fStream.Open(m_strLogFile, CFile::modeWrite, NULL) )
{
if( !fStream.Open(m_strLogFile, CFile::modeWrite | CFile::modeCreate, NULL) )
{
MessageBox("Open or Create of LogFile faild!\nFile: " + m_strLogFile,"Error");
return;
}
}
fStream.WriteString(strBuffer); :confused:
fStream.Close();
CDialog::OnOK();
}




I used the same Object to Write a file with the method WriteString. That works but the problem is i'd like to append Text in a file. However when i open the file with CFile::modeWrite and append data with WriteString the content of the file will be reseted to 0.
Reply With Quote