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]
# 1 Re: CFile::GetLength() only returns part of the size
GetLength() returns actual length of the file. Where did you get 4 KB? This is a typical size of the allocation unit. Was it the size of your file on disk?
VladimirF at 2007-11-11 1:18:11 >
# 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 >
# 4 Re: CFile::GetLength() only returns part of the size
yes, i made a mistake, the file size on the disk is not the same with the real size. thank you !

wxuf
wxuf at 2007-11-11 1:21:07 >