How to write logs to files of size 64KB(to allow notepad to read).Once the file has reached 64KB it should go head and create another , another ...... File names can be automatically generated.
I tried the following code
static int iCounter=1;
CString temp;
static CStdioFile f(L"c:\\Log1.txt", CFile::modeWrite | CFile::modeRead | CFile::modeCreate | CFile::modeNoTruncate);
int nlength = (int)f.GetLength();
if(nlength>(nMaxFileSize*1024))
{
//need to create a new file
f.Close();
iCounter++;
temp.Format(_T("%s%d%s"), "c:\\Log",iCounter, ".txt");
f.Open(temp,CFile::modeWrite | CFile::modeRead | CFile::modeCreate | CFile::modeNoTruncate);
}
f.SeekToEnd();
f.WriteString(str);
f.WriteString(L"\r\n");
i am looking for a better alternative.