CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Location
    Switzerland
    Posts
    58

    (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


    Dan
    --------------------------------------
    It's always nice to see, whether the hints work. I appreciate feedback

  2. #2
    Join Date
    Apr 1999
    Location
    Toronto, ON
    Posts
    713

    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



  3. #3
    Join Date
    May 1999
    Location
    Switzerland
    Posts
    58

    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();




    Dan
    --------------------------------------
    It's always nice to see, whether the hints work. I appreciate feedback

  4. #4
    Join Date
    Apr 1999
    Location
    Toronto, ON
    Posts
    713

    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 WORD dwFlags = INTERNET_FLAG_TRANSFER_ASCII.
    You must change it.



  5. #5
    Join Date
    May 1999
    Location
    Switzerland
    Posts
    58

    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


    Dan
    --------------------------------------
    It's always nice to see, whether the hints work. I appreciate feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured