(CFile) Reading binary file stops at 0x1A, why ?
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
Re: (CFile) Reading binary file stops at 0x1A, why ?
Hi!
How can You read file without openning it?
Check your flags when You open file
Re: (CFile) Reading binary file stops at 0x1A, why ?
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();
Re: (CFile) Reading binary file stops at 0x1A, why ?
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.
Re: (CFile) Reading binary file stops at 0x1A, why ?
Hi,
Thanks a lot for your help. I guess my first question was a bit too slim.
Anyway, it works great.
Regards
Dan