detect endians from file that is loaded in a binarystream?

is there away to detect the endians of a binarystream if data was populated from a folderitem?

is this structured data ?
do you know some values that should be in there ?

the reason I ask is if you know that there are some Uint32 with certain values that are supposed to be at specific offsets then they could be tested to see if they are big or little endian

but if you know nothing about the data or its structure that could be hard
its just bytes and they dont have any specific endianess in and of themselves
only larger items like Int16 int32, int64 etc will

thank you norm.

the files I am working with is DICOM files that have been stored in a PACS archive storage format that doesnt adhere to the standard. i am at a point where I can extract out the files from the archive format, but i am noticing that they have stripped out header details that is needed to make the file whole.

Under normal circumstances, Transfer Syntax UID would be presented which would make it very easy for me to do a look up on a dictionary and see what type of compression and endians the file is. I just wasn’t sure if Transfer Syntax is not presented if there was another way to check.

I will need to research a bit more on the dicom standard if there are Uint32 values that needs to be a specific offset.

ok, here is another question.

in the code below, would this create a mess if dicomMB was Big Endian? dicomMB was populated from binarystream

[code]
var emptyMB as new MemoryBlock(128)
var dicmMB as MemoryBlock = “DICM”
var fixedMB as MemoryBlock

if dicomMB.StringValue(128, 4) = “DICM” then
return dicomMB
else
fixedMB = emptyMB + dicmMB + dicomMB
return fixedMB

end if[/code]

it might since a memoryblock has an endianess property :slight_smile:

thanks norm.

already started making changes