CFile::SetLength
virtual void SetLength( DWORD dwNewLen );
throw( CFileException );ParametersdwNewLenDesired length of the file in bytes. This value can be larger or smaller than the current length of the file. The file will be extended or truncated as appropriate.ResCall this function to change the length of the file.Note With CMemFile, this function could throw a CMemoryException object.
virtual void SetLength( DWORD dwNewLen );
throw( CFileException );ParametersdwNewLenDesired length of the file in bytes. This value can be larger or smaller than the current length of the file. The file will be extended or truncated as appropriate.ResCall this function to change the length of the file.Note With CMemFile, this function could throw a CMemoryException object.
then SetEndOfFile( )
Note that it is not an error to set the file pointer to a position beyond the end of the file. The size of the file does not increase until you call the SetEndOfFile, WriteFile, or WriteFileEx function. A write operation increases the size of the file to the file pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.