1
Reply

Converting Byte Array to Integer Array

tom jones

tom jones

Feb 11 2014 10:11 AM
846
//I AM TRYING TRANPOSE ALL THE BYTE ARRAY VALUES INTO INTEGER VALUES IN THE INTEGER ARRAY
//THE LAST LINE DOES NOT WORK
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Applica
{
class Program
{
static void Main(string[] args)
{
long Totbyte = 0;
string filePath = null;
DirectoryInfo da = new DirectoryInfo("C:\\Folder");
FileInfo[] Arr = da.GetFiles();

foreach (FileInfo ap in Arr)
{
Totbyte = ap.Length;
filePath = ap.FullName;
}

string temPath = Path.GetTempFileName();
byte[] data = new byte[Totbyte];////////////////////////BYTE ARRAY

if (File.Exists(temPath))
{
data = File.ReadAllBytes(filePath);
File.WriteAllBytes(temPath, data);
}//I AM TRYING TRANPOSE ALL THE BYTE ARRAY VALUES INTO INTEGER VALUES IN THE INTEGER ARRAY
int[] arry = new int[Totbyte];////////////////////////INTEGER ARRAY
for (int count = 0; count < data.Length; count++)
{
arry[count] = Convert.ToDecimal(BitConverter.ToInt(data,count));//THIS LINE DOES NOT WORK
}
}
}
}


Answers (1)