Xeren
♦♦♦ God Complex ♦♦♦
I want to read an Int32 from bytes(00E7), but evertime I do it comes as 5000(something like that). I need to reverse it so it will read 231. I've tried Array.Reverse and other methods, but no result.
No I have not.Have you tried reading the bytes in a different order, such as changing the Endian from Big to Small?
Int16 myint = IPAddress.HostToNetworkOrder(binaryReader.ReadInt16());
using System;
using System.IO;
namespace PS3_Packager
{
class BigEndianReader : BinaryReader
{
private byte[] a16 = new byte[2];
private byte[] a32 = new byte[4];
private byte[] a64 = new byte[8];
public BigEndianReader(Stream stream) : base(stream) { }
public override int ReadInt32()
{
a32 = base.ReadBytes(4);
Array.Reverse(a32);
return BitConverter.ToInt32(a32, 0);
}
public Int16 ReadInt16()
{
a16 = base.ReadBytes(2);
Array.Reverse(a16);
return BitConverter.ToInt16(a16, 0);
}
public Int64 ReadInt64()
{
a64 = base.ReadBytes(8);
Array.Reverse(a64);
return BitConverter.ToInt64(a64, 0);
}
public UInt32 ReadUInt32()
{
a32 = base.ReadBytes(4);
Array.Reverse(a32);
return BitConverter.ToUInt32(a32, 0);
}
}
}
BigEndianReader reader = new BigEndianReader(new FileStream(pkgFile, FileMode.Open));