No announcement yet.

[CLOSED] [#3497] Trouble reading binary files

  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] [#3497] Trouble reading binary files


    I've been trying to read out binary files using BinaryReader and File.ReadAllBytes, with no succes. I've created a small demo to show off the problem I'm having:

    byte[] contents = File.ReadAllBytes(path);
    The C# line of code reading the file.

    Click image for larger version  Name:	Expected.png Views:	1 Size:	4.5 KB ID:	5300
    The file I'm trying to read in. First 5 values counting from 0x7E to 0x82.

    Click image for larger version  Name:	Result.png Views:	1 Size:	54.2 KB ID:	5301
    The resulting values when I'm reading the file. (0x7E, 0x7F, 0xFD, 0xFD, 0xFD, 0x7E, 0x7F)
    This does not match the file I'm trying to read in. All values > 127 (0x7F) are set to 253 (0xFD).

    Is this intentional behavior? If so, how would I read this file properly?

    Last edited by fabricio.murta; 2018-03-29 @ 01:12 AM.

    Hi Thom,

    Thanks for the report. I'll look into this scenario and try to figure out what's going wrong.


      Can you provide a copy or sample of the file you're trying to read? something we can use to reproduce the problem.


        Hello Geoffrey,

        I've included the file I was trying to read. (I changed the extension from .bff to .txt so I could upload it here)
        The file is used to read in font data. The first few bytes are modified for easy testing.

        Attached Files
        Last edited by Thom; 2018-03-26 @ 07:31 AM.


          Hi Thom,

          It looks like the issue is related to data encoding. Could you update one line of the ReadBytes function's body and confirm whether it fixes the issue for you?

          // Actual:
          req.overrideMimeType("text/plain; charset=binary-data");
          // Revised:
          req.overrideMimeType("text/plain; charset=x-user-defined");


            Hello Andrey,

            Looks like that fixes the problem I was having! Thanks for the quick support! :)


              Hi Thom. We're looking further into this issue and might be able to revise the logic to handle your original ReadAllBytes scenario without modifying the MimeType.

              We'll keep this thread updated with our progress.


                Issue #3497 has been created to track the defect.


                  Andrey also created a pull request fixing the issue and the fix has just been merged in our integration branch. So that this fix will be available in our next Bridge release! Currently it is slated to be version 17.0.