You can try the following method it works
First read the first string and store it
append it to the end of the string you want to insert at top
Insert the combined string at top
this new string will replace the old first string at the top of the file but anyway the inserted new string contains the old string in it
Code:
void CMyClass::AddTextAt TheTopOf TheFile(LPCTSTR szFile, LPCTSTR szText)
{
if ((szText == NULL) || (szText == "")) return ;
CString str;
char s[81];
CFile file;
if (!file.Open(szFile, CFile::modeRead)) return ;
file.SeekToBegin();
int bytesRead = file.Read(s, 80);
s[bytesRead] = 0;
CString message = s;
file.Close();
if (!file.Open(szFile, CFile::modeWrite)) return ;
file.SeekToBegin();
str.Format("%s\n%s\n",szText,message);
file.Write(str,str.GetLength());
file.Close();
}
Only problem is you have to open the file twice once in Read mode once in Write mode. hope this helps
Thanks