VAGSuite.Tools.readdatafromfileasint C# (CSharp) Méthode

readdatafromfileasint() public méthode

public readdatafromfileasint ( string filename, int address, int length, EDCFileType type ) : int[]
filename string
address int
length int
type EDCFileType
Résultat int[]
        public int[] readdatafromfileasint(string filename, int address, int length, EDCFileType type)
        {
            int[] retval = new int[length];
            FileStream fsi1 = File.OpenRead(filename);
            while (address > fsi1.Length) address -= (int)fsi1.Length;
            BinaryReader br1 = new BinaryReader(fsi1);
            fsi1.Position = address;
            string temp = string.Empty;

            for (int i = 0; i < length; i++)
            {
                if (type != EDCFileType.EDC16)
                {
                    int iVal = Convert.ToInt32(br1.ReadByte());
                    iVal += Convert.ToInt32(br1.ReadByte()) * 256;
                    retval.SetValue(iVal, i);
                }
                else
                {
                    int iVal = Convert.ToInt32(br1.ReadByte()) * 256;
                    iVal += Convert.ToInt32(br1.ReadByte());
                    retval.SetValue(iVal, i);
                }
            }
            // little endian, reverse bytes
            //retval = reverseEndian(retval);
            fsi1.Flush();
            br1.Close();
            fsi1.Close();
            fsi1.Dispose();
            return retval;
        }