BinaryReader br = new BinaryReader(new FileStream(pathArchivo, FileMode.Open, FileAccess.Read));
// Leo los primeros 40 sBytes
sbyte[] prueba = new sbyte[40];
for (int i = 0; i < 40; i++) {
sbyte sb = br.ReadSByte();
prueba[i] = sb;
}
// Intento recuperar los datos
Recupera(prueba, 0);
// -----------------------------------------------
public void Recupera(sbyte[] arr, int offset) {
_time = getLong(arr, offset);
_d1= getDouble(arr, offset+ 1 * 8);
_d2= getDouble(arr, offset+ 2 * 8);
_d3= getDouble(arr, offset+ 3 * 8);
_d4= getDouble(arr, offset+ 4 * 8);
}
// -----------------------------------------------
private long getLong(sbyte[] arr, int offset) {
return ((arr[offset+ 7] & 0xFFL) << 0) +
((arr[offset+ 6] & 0xFFL) << 8) +
((arr[offset+ 5] & 0xFFL) << 16) +
((arr[offset+ 4] & 0xFFL) << 24) +
((arr[offset+ 3] & 0xFFL) << 32) +
((arr[offset+ 2] & 0xFFL) << 40) +
((arr[offset+ 1] & 0xFFL) << 48) +
(((long)b[offset+ 0]) << 56);
}
// -----------------------------------------------
private double getDouble(sbyte[] arr, int offset) {
long j = ((arr[offset+ 7] & 0xFFL) << 0) +
((arr[offset+ 6] & 0xFFL) << 8) +
((arr[offset+ 5] & 0xFFL) << 16) +
((arr[offset+ 4] & 0xFFL) << 24) +
((arr[offset+ 3] & 0xFFL) << 32) +
((arr[offset+ 2] & 0xFFL) << 40) +
((arr[offset+ 1] & 0xFFL) << 48) +
(((long)b[offset+ 0]) << 56);
return (double)(j);
}
// -----------------------------------------------