Hi guys,
I've problem reading a binary file, however it's successful in reading non-binary files such as text/wri files.
Specifically, the buffer reads NULL bytes and gives me ASSERT(lpBuf != NULL) from filecore.cpp, line 243. But, why is this just happening for binary files and not for the non-binary ones? I've tried the c runtime function fread() and it fails on the 2nd attempt of the loop yielding some 9 odd bytes of read bytes even when reading large files (400kb).
This is the code:
CFile pFile (sFilename, CFile::modeRead);
int iReadSize = 0;
while(true){
iReadSize = pFile.Read(pBuf, 4096);
if(iReadSize == 0)
break;
else{
//my processing goes here
}
}
pFile.Close();
Any suggestions please?
Thank you.
Comments
:
: I've problem reading a binary file, however it's successful in reading non-binary files such as text/wri files.
: Specifically, the buffer reads NULL bytes and gives me ASSERT(lpBuf != NULL) from filecore.cpp, line 243. But, why is this just happening for binary files and not for the non-binary ones? I've tried the c runtime function fread() and it fails on the 2nd attempt of the loop yielding some 9 odd bytes of read bytes even when reading large files (400kb).
:
: This is the code:
:
:
: CFile pFile (sFilename, CFile::modeRead);
: int iReadSize = 0;
: while(true){
:
: iReadSize = pFile.Read(pBuf, 4096);
: if(iReadSize == 0)
: break;
: else{
: //my processing goes here
: }
: }
: pFile.Close();
:
:
: Any suggestions please?
: Thank you.
:
:
hiya try using the flag "CFile::typeBinary", for binary files.
if this doesn't work try looking at the CFile class in MSDN for help.
good luck.
: :
: : I've problem reading a binary file, however it's successful in
: hiya try using the flag "CFile::typeBinary", for binary files.
: if this doesn't work try looking at the CFile class in MSDN for help.
:
: good luck.
:
I tried this even b4 you suggested it.
Jey
char unsigned buf[20000];
CFile f;
f.Open(CString("C:\Downloads\steg_1.bmp"), CFile::modeReadWrite|CFile::typeBinary);
UINT bytesRead = f.Read(buf, 20000);
f.Close();
char unsigned buf[20000];
CFile f;
f.Open(CString("C:\Downloads\steg_1.bmp"), CFile::modeReadWrite|CFile::typeBinary);
UINT bytesRead = f.Read(buf, 20000);
f.Close();
char unsigned buf[20000];
CFile f;
f.Open(CString("C:\Downloads\steg_1.bmp"), CFile::modeReadWrite|CFile::typeBinary);
UINT bytesRead = f.Read(buf, 20000);
f.Close();
char unsigned buf[20000];
CFile f;
f.Open(CString("C:\Downloads\steg_1.bmp"), CFile::modeReadWrite|CFile::typeBinary);
UINT bytesRead = f.Read(buf, 20000);
f.Close();
char unsigned buf[20000];
CFile f;
f.Open(CString("C:\Downloads\steg_1.bmp"), CFile::modeReadWrite|CFile::typeBinary);
UINT bytesRead = f.Read(buf, 20000);
f.Close();