CFile::GetLength() only returns part of the size
hi...
I want to read all the file content to a buffer by the following codes.
CFileException fileException ;
file.Open( m_strFileName, CFile::modeRead | CFile::shareDenyNone, &fileException ) ;
m_dwFileSize = file.GetLength() ;
delete []m_pFileContent ;
m_pFileContent = new TCHAR[m_dwFileSize +1] ;
m_pFileContent[m_dwFileSize] = 0 ;
// read the file content to the temp buffer.
file.Read( m_pFileContent, m_dwFileSize ) ;
// close file ;
file.Close() ;
but the size from CFile::GetLength() only returns part of the size.
ie. file size is 4 kilo bytes, it returns 1206 bytes. what is wrong ?
wxuf
[745 byte] By [
wxuf] at [2007-11-18 19:15:21]

# 2 Re: CFile::GetLength() only returns part of the size
From the file property, i find its size is 4 k.
and when i read, only part of the contents are read..
wxuf
wxuf at 2007-11-11 1:19:09 >

# 3 Re: CFile::GetLength() only returns part of the size
Are you maybe confusing 'size' with 'size on disk'. I use Windows XP and when I right click on a file using Explorer it reports the size and also the size on disk. This 'size on disk' is always a multiple of the cluster size (8KB, on my particular system). So, even the very smallest file reports at least 8KB. But that's only the amount of space it's taking up - not the actual size. You can find out the actual number of bytes from the same properties box.
John E at 2007-11-11 1:20:07 >
