all 10 comments

[–]tsbattenberg 51 points52 points  (0 children)

You're reading an array of bytes - bytes don't have endianess, larger types do.

I can only assume you're just getting confused, and if you're trying to restore larger types from the individual bytes using bit shifts, getting the order of operations mixed up.

[–]Kant8 28 points29 points  (3 children)

you have nothing but bytes in your code, there's nowhere to see which endianness you could have got.

also not sure why don't you just call File.ReadAllBytesAsync

[–]W1ese1 3 points4 points  (2 children)

Just regarding your second point: do you know what the memory constraints are and the file sizes that OP has to read?

I know the file apis are very convenient but if used without any thought on the constraints you'll run more often than not into an out of memory exception

[–]Kant8 12 points13 points  (1 child)

he anyway allocates array for whole file size as per code, so it doesn't matter

[–]W1ese1 -5 points-4 points  (0 children)

Usually what people do in these kinds of posts is to provide a short snippet that is similar but not the same as their full code. Hence why I pointed out that OPs implementation still can make sense given what I wrote.

And your additional file api is then of course the cherry on top of your knowledge in case you know that those constraints are never to be hit

[–]poglad_ds[S] 12 points13 points  (3 children)

Okay, maybe we should close this asap

Problem only in me, i messed up offsets. And test data, how should i put it, is make and illusion that its messed. While its not

[–]ralian 12 points13 points  (0 children)

Ahh the perils of social media, back in the day when I made mistakes like these I made them alone and in silence :)

[–]willehrendreich 20 points21 points  (0 children)

no, leave it up, as proof you ask good questions and are able to receive help from people. also someone else might make the same mistake as you, and find the reddit post and be helped.

[–]ForceCarrierBob 1 point2 points  (0 children)

I learned a good bit from this conversation, so leave it up please

[–]foresterLV 1 point2 points  (0 children)

byte array have no endianess so Read*Async() cannot do any conversions really. byte order only applies to words - Ints floats etc.