How to insert data to the top of exist text file?
I want to insert "{" to the top of exist text file and insert "}" to the bottom of text file
Example:
If in "1.txt" has this data in it.
1234afd
daf845
dfdfa
and I want to insert "{" to the top of text file and insert "}" to the bottom of text file. So I think it should be like this
{
1234afd
daf845
dfdfa
}
I write program to do that. But my program replace "{" to the first line data of "1.txt"
So my program write this data in "1.txt"
{
daf845
dfdfa
}
Below is my program.
Code:
CStdioFile OutputFile;
CString outp_filename, m_string;
CFileException FileExc;
BOOL bEnd;
outp_filename = "1.txt";
if (!OutputFile.Open(outp_filename, CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate, &FileExc))
{
FileExc.ReportError();
return;
}
OutputFile.SeekToBegin();
m_string = "{";
OutputFile.WriteString(m_string+'\n');
OutputFile.SeekToEnd();
m_string = "}";
OutputFile.WriteString(m_string+'\n');
OutputFile.Close();
}
Do you know how to solve my problem?
Thank you very much.