Click to See Complete Forum and Search --> : (CFile) Reading binary file stops at 0x1A, why ?


Daniel Frey
June 5th, 1999, 10:28 AM
Hi,
I want to read a binary file with CFile.
Something like this:

CFile file("hhh", FLAGS);
file.Read(buffer, 4096) ..

But the readings stops when it encounters a 0x1A. How is it possible to read any binaray file,
in my case a JPG-file ??

Thanks in advance
Dan

Dmitriy
June 5th, 1999, 10:43 AM
Hi!
How can You read file without openning it?
Check your flags when You open file

Daniel Frey
June 5th, 1999, 10:59 AM
it was just a sample, the minimum you have to know
I want to read from the internet OR from a file from hard-disk.

the complete code here


int iNumberOfBytesRead;
char buffer[4096];

CInternetSession internetSession("PicScan");
CInternetFile * internetFile = (CInternetFile *)internetSession.OpenURL("E:\\Developper\\Image\\flower.jpg");
CString strFileName = "test";
CFile fileSave(strFileName, CFile::modeCreate | CFile::modeReadWrite);

while (1)
{
iNumberOfBytesRead = internetFile->Read(buffer, 4096);
fileSave.Write(buffer, iNumberOfBytesRead);
if (iNumberOfBytesRead == 0)
break;
}

internetFile->Close();

Dmitriy
June 5th, 1999, 11:23 AM
Well. In this case see definition of internetSession.OpenURL(). By default you have ASCII_TEXT mode :DWORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII.
You must change it.

Daniel Frey
June 6th, 1999, 04:37 AM
Hi,
Thanks a lot for your help. I guess my first question was a bit too slim.
Anyway, it works great.

Regards
Dan