I am using MFC CFile Seek function. I have a problem about Seek out of file length.
CFile cfile;
BOOL bResult = cfile.Open(
L"C:\\2.TXT",
CFile::modeReadWrite |
CFile::modeCreate |
CFile::modeNoTruncate |
CFile::typeBinary |
CFile::shareDenyNone);
cfile.Seek(10000, CFile::End);
cfile.Close();
MSDN: Remarks
The Seek function permits random access to a file's contents by moving the pointer a specified amount, absolutely or relatively. No data is actually read during the seek. If the requested position is larger than the size of the file, the file length will be extended to that position, and no exception will be thrown.
According to MSDN, the file length will be extended.
However after cfile.Close()
, the file remains the same.
Why?Many thanks!