Trouble getting file size...
Whenever I attempt to use the following code, it returns an invalid length if I try to open a BMP or other binary file, but it works fine with text files. Any ideas why?
PHP Code:
#include <stdio.h>
#include <conio.h>
#include <fstream.h>
long GetFileLen(const char *);
long GetFileLen(const char *FilePath)
{
long RetVal = 0;
unsigned char TempChar;
ifstream TheFile;
TheFile.open(FilePath);
while(!TheFile.eof())
{
TheFile.get(TempChar);
RetVal++;
}
TheFile.close();
return RetVal;
}
int main()
{
long FileLen;
FileLen = GetFileLen("C:/asdf.bmp");
printf("%ld",FileLen);
getch();
return 0;
}